Skip to content

MakerBundle "enum" entity type prompts "Can this field store multiple enum values" but doesn't handle the case #1580

Closed
@dalioscode

Description

@dalioscode

Symfony version(s) affected

7.1.2

Description

When creating a field of type "enum" for an entity with Symfony MakerBundle, after setting the enum, the CLI prompts you to choose whether the field can store multiple enum values or not. Choosing yes correctly generates the code by passing the enum to the field's attribute and setting the type to "SIMPLE_ARRAY" but then throws the following error when trying to save the form.
"Expected argument of type "your Enum", "array" given at property path "your field".

How to reproduce

Create a valid string backed enum and run php bin/console make:entity. Enter whatever name, choose enum as the field type and specify your enum's full class name (e.g.: App\Enum\MyEnum). There is the most important step. When prompted "Can this field store multiple enum values", choose yes. Then create a form for this entity, make the field an EnumType, specify your Enum class name and set "multiple" to true. When sending the form, the error will be displayed. (while you would expect it to work out of the box as any MakerBundle generated code)

Possible Solution

No response

Additional Context

Setup and errors (entity code was generated by MakerBundle and is untouched)
image
image
image
image
image

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