Skip to content

Extending Tom Select with a custom Stimulus controller #545

@iampedropiedade

Description

@iampedropiedade

I've followed documentation for extending TomSelect with a custom Stimulus controller.
https://symfony.com/bundles/ux-autocomplete/current/index.html#extending-tom-select

However, when I added the attr option:

public function configureOptions(OptionsResolver $resolver)
{
    $resolver->setDefaults([
        'class' => Food::class,
        'attr' => [
            'data-controller' => 'custom-autocomplete',
         ],
    ]);
}

the select element became a regular select instead of a TomSelect.

The only way I got it to work was by adding both my custom Stimulus controller and the default controller, like this:

public function configureOptions(OptionsResolver $resolver)
{
    $resolver->setDefaults([
        'class' => Food::class,
        'attr' => [
            'data-controller' => 'custom-autocomplete symfony--ux-autocomplete--autocomplete',
         ],
    ]);
}

I am unsure if the above is the correct way to use custom controllers and documentation is incorrect or if this is a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions