Closed vesselind closed 5 months ago
When the choices
option is set, the Doctrine loader is omitted, meaning that you don't need a loader at all as your choices are hardcoded. Thus, the parent loader will be null
In your case, in the meantime, you can fix it by setting choice_loader
to null
directly.
In our case, we should update BaseEntityAutocompleteType
so we ignore the ExtraLazyChoiceLoader
if the parent $loader
is null
which is the case here:
$choiceLoader = static function (Options $options, $loader) {
if (null === $loader) {
return null;
}
return new ExtraLazyChoiceLoader($loader);
};
@vesselind would you like send a PR fixing it?
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 oneBaseEntityAutocompleteType::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:
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.