Skip to content

Commit

Permalink
bug #1775 #1770 [Autocomplete] Ignore the ExtraLazyChoiceLoader if th…
Browse files Browse the repository at this point in the history
…e parent $loader is null (vesselind)

This PR was merged into the 2.x branch.

Discussion
----------

#1770 [Autocomplete] Ignore the ExtraLazyChoiceLoader if the parent $loader is null

| Q             | A
| ------------- | ---
| Bug fix?      | yes/no
| New feature?  | no
| Issues        | Fix #1770
| License       | MIT

When a custom autoload field class is created and `choices` option is passed, an error occurs: `Symfony\UX\Autocomplete\Form\ChoiceList\Loader\ExtraLazyChoiceLoader::__construct(): Argument #1 ($decorated) must be of type Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface, null given`.

This should fix the problem, described in #1770.

Commits
-------

28af7fc #1770 ignore the ExtraLazyChoiceLoader if the parent $loader is null
  • Loading branch information
kbond committed Apr 24, 2024
2 parents c852c5a + 28af7fc commit 25278fd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Autocomplete/src/Form/BaseEntityAutocompleteType.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
public function configureOptions(OptionsResolver $resolver): void
{
$choiceLoader = static function (Options $options, $loader) {
if (null === $loader) {
return null;
}

return new ExtraLazyChoiceLoader($loader);
};

Expand Down

0 comments on commit 25278fd

Please sign in to comment.