From d6bbd4938f61bee0908f6fed4008c2cb1dbc4236 Mon Sep 17 00:00:00 2001 From: Piotr Januszewski Date: Thu, 7 Sep 2023 11:30:56 +0200 Subject: [PATCH] Autocomplete attr support (#8083) Co-authored-by: Piotr Januszewski --- docs/reference/form_types.rst | 12 ++++++++++++ .../Type/sonata_type_model_autocomplete.html.twig | 3 +-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/reference/form_types.rst b/docs/reference/form_types.rst index f566c393c7..196da36895 100644 --- a/docs/reference/form_types.rst +++ b/docs/reference/form_types.rst @@ -483,6 +483,18 @@ The available options are: } } +``attr`` + An array of arbitrary attributes which will be rendered inside the select tag:: + + $form + ->add('category', ModelAutocompleteType::class, [ + 'property' => 'title', + 'attr' => [ + 'data-my-custom-variable' => 'my-custom-value', + ], + ]) + ; + Sonata\\AdminBundle\\Form\\Type\\ChoiceFieldMaskType ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/Resources/views/Form/Type/sonata_type_model_autocomplete.html.twig b/src/Resources/views/Form/Type/sonata_type_model_autocomplete.html.twig index bd909e532f..d19934f66a 100644 --- a/src/Resources/views/Form/Type/sonata_type_model_autocomplete.html.twig +++ b/src/Resources/views/Form/Type/sonata_type_model_autocomplete.html.twig @@ -10,9 +10,9 @@ file that was distributed with this source code. #} {% apply spaceless %}