You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
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, chooseenum
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 anEnumType
, 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)
The text was updated successfully, but these errors were encountered: