ux icon indicating copy to clipboard operation
ux copied to clipboard

[Autocomplete + Live Component] Validation issue when using an autocomplete field in a live component

Open MelaineGerard opened this issue 2 years ago • 2 comments

Hello ! I've found an issue when using an autocomplete field in a live component. The autocomplete field is configured with these options :

$builder
            ->add('emails', ChoiceType::class, [
                'multiple' => true,
                'autocomplete' => true,
                'tom_select_options' => [
                    'create' => true,
                ],
                'label' => 'Email of the team members',
                'attr' => [
                    'placeholder' => 'Email of the team members',
                ]
            ])
        ;

But, when I add a choice, I have a 422 error in javascript console and a form errror with value "The selected choice is invalid."

Record bug symfony ux

You can reproduce the issue with this simple project

PHP Version : 8.2 Symfony version : 7.0 Asset Mapper version : 7.0 Symfony UX Version : 2.13.3

MelaineGerard avatar Dec 28 '23 09:12 MelaineGerard

There are some known issues with Autocomplete + Live + multiple https://symfony.com/bundles/ux-autocomplete/current/index.html#known-issue-when-using-with-live-component

I’ll take a look later today but i dont want to give you too much hope :/

smnandre avatar Dec 28 '23 09:12 smnandre

This is just a shortcoming of the autocomplete library, or rather a missing feature. You can set the create option to allow creating on the frontend, but there's no mechanism to handle that on the backend - i.e. by persisting a new item to the database.

weaverryan avatar Jan 22 '24 01:01 weaverryan