Skip to content

Commit 4ccf5f6

Browse files
raphael-geffroyKocal
authored andcommitted
[Autocomplete] Add documentation about plugins management
1 parent 08097bc commit 4ccf5f6

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/Autocomplete/doc/index.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ e.g. ``FoodAutocompleteField`` from above):
206206
``tom_select_options`` (default: ``[]``)
207207
Use this to set custom `Tom Select Options`_. If you need to set
208208
an option using JavaScript, see `Extending Tom Select`_.
209+
Read also about `Managing plugins`_.
209210

210211
``options_as_html`` (default: ``false``)
211212
Set to ``true`` if your options (e.g. ``choice_label``) contain HTML. Not
@@ -415,6 +416,36 @@ all of the options - separated by the ``delimiter`` - will be sent as a string.
415416
You *can* add autocompletion to this via the ``autocomplete_url`` option - but you'll
416417
likely need to create your own :ref:`custom autocomplete endpoint <custom-autocomplete-endpoint>`.
417418

419+
Managing plugins
420+
----------------
421+
422+
`Tom Select Plugins`_ can be configured through the ``tom_select_options.plugins`` option:
423+
424+
$resolver->setDefaults([
425+
'class' => Ingredient::class,
426+
'tom_select_options' => [
427+
'plugins' => [
428+
// Enable Input Autogrow plugin
429+
'input_autogrow',
430+
431+
// Enable Dropdown Header plugin, with custom configuration
432+
'dropdown_header' => [
433+
'title' => 'Select an ingredient',
434+
],
435+
436+
// Force natively-enabled plugins (by UX Autocomplete) to be disabled
437+
'clear_button' => false,
438+
'remove_button' => false,
439+
],
440+
],
441+
]);
442+
443+
.. note::
444+
445+
Some configuration could not be supported through the `tom_select_options.plugins` option,
446+
for example when a plugin requires a JavaScript function as configuration value.
447+
In that case, you must use the `Extending Tom Select`_ approach to configure plugins.
448+
418449
Customizing the AJAX URL/Route
419450
------------------------------
420451

@@ -758,3 +789,4 @@ the Symfony framework: https://symfony.com/doc/current/contributing/code/bc.html
758789
.. _`Tom Select Option Group`: https://tom-select.js.org/examples/optgroups/
759790
.. _`Symfony Form`: https://symfony.com/doc/current/forms.html
760791
.. _`@symfony/ux-autocomplete npm package`: https://www.npmjs.com/package/@symfony/ux-autocomplete
792+
.. _`Tom Select Plugins`: https://tom-select.js.org/plugins/

0 commit comments

Comments
 (0)