You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Autocomplete/doc/index.rst
+37-31Lines changed: 37 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ Tom Select-powered UI control by adding the ``autocomplete`` option:
68
68
}
69
69
70
70
That's all you need! When you refresh, the Autocomplete Stimulus controller
71
-
will transform your select element into a smart UI control:
71
+
will transform your ``<select>`` element into a smart UI control:
72
72
73
73
.. image:: food-non-ajax.png
74
74
:alt:Screenshot of a Food select with Tom Select
@@ -99,7 +99,8 @@ Or, create the field by hand::
99
99
// src/Form/FoodAutocompleteField.php
100
100
// ...
101
101
102
-
use Symfony\Bundle\SecurityBundle\Security;
102
+
use Symfony\Component\Form\AbstractType;
103
+
use Symfony\Component\OptionsResolver\OptionsResolver;
103
104
use Symfony\UX\Autocomplete\Form\AsEntityAutocompleteField;
104
105
use Symfony\UX\Autocomplete\Form\BaseEntityAutocompleteType;
105
106
@@ -283,16 +284,22 @@ Passing Extra Options to the Ajax-powered Autocomplete
283
284
284
285
The ability to pass extra options was added in Autocomplete 2.14.
285
286
286
-
Autocomplete field options are not preserved when the field is rendered on an Ajax call. So, features like exclude some options
287
-
based on the current form data are not possible by default. To partially avoid this limitation, the `extra_options` option was added.
287
+
Autocomplete field options are **not preserved** when the field is rendered
288
+
on an Ajax call. So, features like exclude some options based on the current
289
+
form data are not possible by default.
290
+
291
+
To partially avoid this limitation, the ``extra_options`` option was added.
288
292
289
293
.. warning::
290
294
291
-
Only scalar values (``string``, ``integer``, ``float``, ``boolean``), ``null`` and ``array`` (consisted from the same types as mentioned before) can be passed as extra options.
295
+
Only scalar values (``string``, ``integer``, ``float``, ``boolean``),
296
+
``null`` and ``array`` (consisted from the same types as mentioned before)
297
+
can be passed as extra options.
292
298
293
-
Considering the following example, when the form type is rendered for the first time, it will use the ``query_builder`` defined
294
-
while adding a ``food`` field to the ``FoodForm``. However, when the Ajax is used to fetch the results, on the consequent renders,
295
-
the default ``query_builder`` will be used::
299
+
Considering the following example, when the form type is rendered for the first
300
+
time, it will use the ``query_builder`` defined while adding a ``food`` field
301
+
to the ``FoodForm``. However, when the Ajax is used to fetch the results, on
302
+
the consequent renders, the default ``query_builder`` will be used::
296
303
297
304
// src/Form/FoodForm.php
298
305
// ...
@@ -306,21 +313,18 @@ the default ``query_builder`` will be used::
306
313
$builder
307
314
->add('food', FoodAutocompleteField::class, [
308
315
'query_builder' => function (EntityRepository $er) {
0 commit comments