Top menu

Define a default value in configureFormFields

To add some some default field value whith SonataAdminBundle you should use the getNewInstance function :



How to use a callback with SonataAdminBundle sonata_type_model_autocomplete in configureFormFields

The callback in sonata_type_model_autocomplete configuration is a callable function that can be used to modify the query which is used to retrieve autocomplete items. The callback should receive three parameters – the Admin instance, the property (or properties) defined as searchable and the search value entered by the user.



How to use the “getDefaultOptions” to initialize a form field value

In this article I will show you how to create a form by setting a field on a passed value from controller using the getDefaultOptions function :

Now in the controller we can create the form with a default value for the option “userType” that allow us to define the value of the  : […]


How to add no mapped field in form

If you wish the field to be ignored when reading or writing to the object, you can set the property_path option to false.

NB : Since 2.1, the mapped option has been added for this use-case.