select2.rst 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. Select2
  2. =======
  3. The admin comes with `select2 <http://ivaynberg.github.io/select2/>`_ integration
  4. since version 2.2.6. Select2 is a jQuery based replacement for select boxes.
  5. It supports searching, remote data sets, and infinite scrolling of results.
  6. The select2 is enabled on all ``select`` form elements by default.
  7. Disable select2
  8. ---------------
  9. If you don't want to use select2 in your admin, you can disable it in ``config.yml``.
  10. .. configuration-block::
  11. .. code-block:: yaml
  12. sonata_admin:
  13. options:
  14. use_select2: false # disable select2
  15. .. note::
  16. If you disable select2, autocomplete form types will stop working.
  17. Disable select2 on some form elements
  18. -------------------------------------
  19. To disable select2 on some ``select`` form element, set data attribute ``data-sonata-select2="false"`` to this form element.
  20. .. code-block:: php
  21. ->add('category', 'sonata_type_model',
  22. array(
  23. 'attr'=>array('data-sonata-select2'=>'false')
  24. )
  25. )
  26. AllowClear
  27. ----------
  28. Select2 parameter ``allowClear`` is handled automatically by admin. But if you want
  29. to overload the default functionality, you can set data attribute ``data-sonata-select2-allow-clear="true"``
  30. to enable ``allowClear`` or ``data-sonata-select2-allow-clear="false"`` to disable the ``allowClear`` parameter.
  31. .. code-block:: php
  32. ->add('category', 'sonata_type_model',
  33. array(
  34. 'attr'=>array('data-sonata-select2-allow-clear'=>'false')
  35. )
  36. )