Skip to content

[Forms] Allow modifications of choices in Form Events #52709

Closed as not planned
Closed as not planned
@KDederichs

Description

@KDederichs

Description

Hey,
I'm trying to integrate https://symfony.com/doc/current/form/dynamic_form_modification.html into EasyAdminBundle but honestly it's a bit frustrating.

The code itself works well enough BUT since you have to recreate the choice field every time it seems to loose its attributes set by EasyAdmin.

What would be A LOT! easier would be the ability to overwrite just the choices using the Form events, so the elements keep the rest of their configuration.

Example

Could be as simple as something like that:

$event->getForm()->get('someChoice')->replaceChoices([
  "new choice" => "nice"
])

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions