how can i set default value in sonata admin bundle the data option is missing in configureFormFields method
protected function configureFormFields(FormMappe
For booleans, another option is to set a data
value within the first array passed to your add
method, inside of configureFormFields
So after some memtoring, my code (for a checkbox that I wanted to have checked by default) ended up looking something like this:
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('name')
->add('visible', null, ['label'=>'Visibility', 'data' => true ])
;
}
... which saved a few lines at the top of my file, since I could then get rid of the getNewInstance() definition.