@@ -159,34 +159,6 @@ After creating this class, use it in your form:
159
159
these won't be used during the Ajax call to fetch results. Instead, include
160
160
all options inside the custom class (``FoodAutocompleteField ``).
161
161
162
- .. note ::
163
-
164
- .. versionadded :: Unreleased
165
- The default route for Autocomplete components is ``/autocomplete/{alias}/ ``
166
- Sometimes it may be useful to customize this URL - e.g. so that the component lives
167
- under a specific firewall.
168
-
169
- To use another route, you need to declare it :
170
-
171
- .. code-block :: yaml
172
- # config/routes/attributes.yaml
173
- ux_entity_autocomplete_admin :
174
- controller : ux.autocomplete.entity_autocomplete_controller
175
- path : ' /admin/autocomplete/{alias}'
176
-
177
- then specify this new route to your component :
178
-
179
- .. code-block :: diff
180
- // src/Form/FoodAutocompleteField.php
181
- use Symfony\UX\Autocomplete\Form\AsEntityAutocompleteField;
182
- - #[AsEntityAutocompleteField]
183
- + #[AsEntityAutocompleteField(route: 'ux_entity_autocomplete_admin')]
184
- class FoodAutocompleteField
185
- {
186
- // ...
187
- }
188
-
189
-
190
162
Congratulations! Your ``EntityType `` is now Ajax-powered!
191
163
192
164
Styling Tom Select
@@ -305,6 +277,34 @@ all of the options - separated by the ``delimiter`` - will be sent as a string.
305
277
You *can * add autocompletion to this via the ``autocomplete_url `` option - but you'll
306
278
likely need to create your own :ref: `custom autocomplete endpoint <custom-autocomplete-endpoint >`.
307
279
280
+ Customizing the AJAX URL/Route
281
+ ------------------------------
282
+
283
+ .. versionadded :: 2.7
284
+
285
+ The ability to specify the route was added in Twig Components 2.7.
286
+
287
+ The default route for the Ajax calls used by the Autocomplete component is ``/autocomplete/{alias}/ ``.
288
+ Sometimes it may be useful to customize this URL - e.g. so that the URL lives
289
+ under a specific firewall.
290
+
291
+ To use another route, first declare it:
292
+
293
+ .. code-block :: yaml
294
+
295
+ # config/routes/attributes.yaml
296
+ ux_entity_autocomplete_admin :
297
+ controller : ux.autocomplete.entity_autocomplete_controller
298
+ path : ' /admin/autocomplete/{alias}'
299
+
300
+ Then specify this new route on the attribute::
301
+
302
+ // src/Form/FoodAutocompleteField.php
303
+
304
+ #[AsEntityAutocompleteField(route: 'ux_entity_autocomplete_admin')]
305
+ class FoodAutocompleteField
306
+ // ...
307
+
308
308
Extending Tom Select
309
309
--------------------
310
310
0 commit comments