Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
dalioscode opened this issue Jul 25, 2024 · 0 comments · Fixed by #1584
Labels
Bug Bug Fix Status: Needs Review Needs to be reviewed

Comments

@dalioscode
Copy link

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

@dalioscode dalioscode added the Bug Bug Fix label Jul 25, 2024
@carsonbot carsonbot added the Status: Needs Review Needs to be reviewed label Jul 25, 2024
@xabbuh xabbuh transferred this issue from symfony/symfony Jul 26, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug Bug Fix Status: Needs Review Needs to be reviewed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants