Skip to content

Commit 70e2276

Browse files
committed
[Autocomplete] Tweaking new route customization docs
1 parent c3f06ba commit 70e2276

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

src/Autocomplete/doc/index.rst

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -159,34 +159,6 @@ After creating this class, use it in your form:
159159
these won't be used during the Ajax call to fetch results. Instead, include
160160
all options inside the custom class (``FoodAutocompleteField``).
161161

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-
190162
Congratulations! Your ``EntityType`` is now Ajax-powered!
191163

192164
Styling Tom Select
@@ -305,6 +277,34 @@ all of the options - separated by the ``delimiter`` - will be sent as a string.
305277
You *can* add autocompletion to this via the ``autocomplete_url`` option - but you'll
306278
likely need to create your own :ref:`custom autocomplete endpoint <custom-autocomplete-endpoint>`.
307279

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+
308308
Extending Tom Select
309309
--------------------
310310

0 commit comments

Comments
 (0)