From 3abb968f070fd0e43f1f52f0ba847788f8d53363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20K=C3=BChnel?= Date: Thu, 1 Sep 2022 23:51:30 +0200 Subject: [PATCH] [Autocomplete] Fix extending Tom Select when using custom ajax class --- .../src/Resources/views/autocomplete_form_theme.html.twig | 2 +- .../tests/Fixtures/Form/CategoryAutocompleteType.php | 3 +++ .../tests/Functional/AutocompleteFormRenderingTest.php | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Autocomplete/src/Resources/views/autocomplete_form_theme.html.twig b/src/Autocomplete/src/Resources/views/autocomplete_form_theme.html.twig index d62f4470062..7800fed1717 100644 --- a/src/Autocomplete/src/Resources/views/autocomplete_form_theme.html.twig +++ b/src/Autocomplete/src/Resources/views/autocomplete_form_theme.html.twig @@ -1,6 +1,6 @@ {# EasyAdminAutocomplete form type #} {% block ux_entity_autocomplete_widget %} - {{ form_widget(form.autocomplete, { attr: attr|merge({ required: required }) }) }} + {{ form_widget(form.autocomplete, { attr: form.autocomplete.vars.attr|merge({ required: required }) }) }} {% endblock ux_entity_autocomplete_widget %} {% block ux_entity_autocomplete_label %} diff --git a/src/Autocomplete/tests/Fixtures/Form/CategoryAutocompleteType.php b/src/Autocomplete/tests/Fixtures/Form/CategoryAutocompleteType.php index 3a2eadaa1a4..fea1646a711 100644 --- a/src/Autocomplete/tests/Fixtures/Form/CategoryAutocompleteType.php +++ b/src/Autocomplete/tests/Fixtures/Form/CategoryAutocompleteType.php @@ -38,6 +38,9 @@ public function configureOptions(OptionsResolver $resolver) return true; }, 'placeholder' => 'What should we eat?', + 'attr' => [ + 'data-controller' => 'custom-autocomplete', + ], ]); } diff --git a/src/Autocomplete/tests/Functional/AutocompleteFormRenderingTest.php b/src/Autocomplete/tests/Functional/AutocompleteFormRenderingTest.php index f03e749537b..7c1acb3eef0 100644 --- a/src/Autocomplete/tests/Functional/AutocompleteFormRenderingTest.php +++ b/src/Autocomplete/tests/Functional/AutocompleteFormRenderingTest.php @@ -29,7 +29,7 @@ public function testFieldsRenderWithStimulusController() $this->browser() ->throwExceptions() ->get('/test-form') - ->assertElementAttributeContains('#product_category_autocomplete', 'data-controller', 'symfony--ux-autocomplete--autocomplete') + ->assertElementAttributeContains('#product_category_autocomplete', 'data-controller', 'custom-autocomplete symfony--ux-autocomplete--autocomplete') ->assertElementAttributeContains('#product_category_autocomplete', 'data-symfony--ux-autocomplete--autocomplete-url-value', '/test/autocomplete/category_autocomplete_type') ->assertElementAttributeContains('#product_portionSize', 'data-controller', 'symfony--ux-autocomplete--autocomplete')