From 450904cd037fa58adf5bec3f8e20b197cd020d3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georgijs=20K=C4=BCavi=C5=86=C5=A1?= Date: Wed, 20 Jan 2021 16:12:25 +0200 Subject: [PATCH] Added docs --- docs/reference/form_types.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/reference/form_types.rst b/docs/reference/form_types.rst index 4a3b6890aa..916a7db2de 100644 --- a/docs/reference/form_types.rst +++ b/docs/reference/form_types.rst @@ -315,6 +315,18 @@ The available options are: ]) ; +``response_item_callback`` + defaults to ``null``. Callable function that can be used to customize each item individually returned in JSON:: + + $formMapper + ->add('category', ModelAutocompleteType::class, [ + 'property' => 'title', + 'response_item_callback' => function ($admin, $entity, &$item) { + $item['type'] = $entity->getType(); + }, + ]) + ; + ``multiple`` defaults to ``false``. Set to ``true``, if your field is in a many-to-many relation. @@ -408,6 +420,12 @@ The available options are: {# change the default selection format #} {% block sonata_type_model_autocomplete_selection_format %}''+item.label+''{% endblock %} + {# customize select2 options #} + {% block sonata_type_model_autocomplete_select2_options_js %} + options.multiple = false; + options.dropdownAutoWidth = false; + {% endblock %} + ``target_admin_access_action`` defaults to ``list``. By default, the user needs the ``LIST`` role (mapped to ``list`` access action)