Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Autocomplete] Tom Select Options Plugins #2656

Open
luchidalgo opened this issue Mar 24, 2025 · 0 comments
Open

[Autocomplete] Tom Select Options Plugins #2656

luchidalgo opened this issue Mar 24, 2025 · 0 comments
Labels

Comments

@luchidalgo
Copy link
Contributor

I create a new autocomplete field with AJAX capabilities using #[AsEntityAutocompleteField] attribute and extending AbstractType.

When I configure the field, I want to add a plugin on tom-select using tom_select_options -> plugins configuration :


#[AsEntityAutocompleteField]
class AdminCompanyAutocompleteField extends AbstractType
{
    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'class' => Company::class,
            'choice_label' => 'label',
            'searchable_fields' => ['label'],
            'security' => User::ROLE_ADMIN,
            'multiple' => false,
            'tom_select_options' => [
                'plugins' =>  ['dropdown_input']
            ]
        ]);
    }

    public function getParent(): string
    {
        return BaseEntityAutocompleteType::class;
    }
}

The problem is this part overwrite the Tom select plugins configuration done in controller.ts :

           'tom_select_options' => [
                'plugins' =>  ['dropdown_input']
            ]

Overwriting at : https://github.com/luchidalgo/ux/blob/ab44abfd74ea319e8c2902af8abd7408e7eb3d5e/src/Autocomplete/assets/src/controller.ts#L217

Maybe we should use deep merge instead of shallow merge ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants