I have a check box that Renders correctly . If there is no data from the database I want the check box to be checked by default.
If I set "data" = True
it displays the checkbox checked. Now if I get the data from the database it won't override the checkbox to the boolean value of false. If I remove the data" => true then I am able to get the correct checkbox from the database but I am not able to set the default checkbox.
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('isFieldFirstname', 'checkbox', array(
'label' => 'Show First Name',
'required' => false,
"data" => true,
)
)
Just to recap
- Database - No record found - show default checkbox as checked
- If record found use value from database ex isFieldFirstname = false checkbox unchecked
Aucun commentaire:
Enregistrer un commentaire