New to symfony2, I have a simple table with two fields.
Since the alert field is a boolean, I declared the form as follows:
public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('message', 'text', array('label' => "Message")) ->add('alert', 'choice', array( 'choices' => array(1 => 'Yes', 0 => 'No'), 'expanded' => true, 'multiple' => false, 'label' => "Are you agree?", 'attr' => array('class' => 'well') )); }
It works when I create a new record, but when I try to edit the record, the "alert" option stored in the database is not set in the form (radio button).
How to set the state of a database on a form?
source share