Skip to content

Filter + EntityFilter + Autocomplete + custom choice_label = 💥 #7462

@lyrixx

Description

@lyrixx

Describe the bug
I want to use an EntityFilter, with an autocomplete and a custom choice label.
It works as expected without autocomplete.

Image

BUT as soon as I add ->autocomplete() it crashes:

An error has occurred resolving the options of the form "EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudAutocompleteType": The option "choice_label" does not exist. Defined options are: "action", "allow_extra_fields", "allow_file_upload", "attr", "attr_translation_parameters", "auto_initialize", "block_name", "block_prefix", "by_reference", "class", "compound", "constraints", "csrf_field_name", "csrf_message", "csrf_protection", "csrf_token_id", "csrf_token_manager", "data", "data_class", "disabled", "ea_crud_form", "ea_vars", "empty_data", "error_bubbling", "error_mapping", "extra_fields_message", "form_attr", "getter", "help", "help_attr", "help_html", "help_translation_parameters", "inherit_data", "invalid_message", "invalid_message_parameters", "is_empty_callback", "label", "label_attr", "label_format", "label_html", "label_translation_parameters", "mapped", "method", "multiple", "post_max_size_message", "priority", "property_path", "required", "row_attr", "setter", "translation_domain", "trim", "upload_max_size_message", "validation_groups".

To Reproduce

    public function configureFilters(Filters $filters): Filters
    {
        return $filters
            ->add(EntityFilter::new('plan')
                ->autocomplete() // This line make the applications crashes
                ->setFormTypeOption('value_type_options', [
                    'choice_label' => static function (Plan $plan) {
                        return $plan->name . ' [' . $plan->project->getNameWithOrganization() . ']';
                    },
                ])
            )
        ;
    }

may be related to #7419

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions