symfonyeasyadmintom-select

How can I use Tomselect in an easyadmin filter


In easyadmin we can use the pretty cool Tomselect library in an entity crud form https://symfony.com/doc/current/EasyAdminBundle/fields/AssociationField.html

But how can I use this library in a filter?


Solution

  • If you want to use tomselect in a layout from easy admin (which then include easy admin javascript), you can define a select as a tomselect widget.

    Just add html attribute data-ea-widget="ea-autocomplete" on your select and it should become a tom select. This is done automatically when using a select in a form but nothing prevent you from doing it manually.

    Or if you are using webpack, you could just import TomSelect and use it.

    import TomSelect from 'tom-select'
    
    new TomSelect('#select_id')