Skip to content

[Autocomplete] AJAX Autocomplete not working after upgrade to v.2.17 - ExtraLazyChoiceLoader problem #1770

Closed
@vesselind

Description

@vesselind

I have my own custom autocompleteField class which worked properly till now. After upgrading the ux-autocomplete to v.2.17 and replacing the parent class ParentEntityAutocompleteType::class with the new one BaseEntityAutocompleteType::class I receive the following error:
Symfony\UX\Autocomplete\Form\ChoiceList\Loader\ExtraLazyChoiceLoader::__construct(): Argument #1 ($decorated) must be of type Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface, null given, called in D:\laragon\www\youcook.online\vendor\symfony\ux-autocomplete\src\Form\BaseEntityAutocompleteType.php on line 41

Here is the code of my class:

public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'class' => RecipeCategory::class,
            'placeholder' => 'placeholder.recipe_category',
            'choices' =>  $this->treeBuilder->buildTree(),
            'choice_label' => function ($category) {
                return sprintf('%s %s', str_repeat('-', $category->level), $category);
            },
        ]);
    }

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

Perhaps the problem has something to do with the choices option. I pass the $this->treeBuilder->buildTree() which returns an array. This seemed to be okay in the past, but somehow is problematic now.

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