-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
… given (Uplink03, Radu Cristescu) This PR was merged into the 4.x branch. Discussion ---------- Fix ChoiceField when entity is enumType and no choices were given Fix ChoiceField when entity is enumType and no choices were given explicitly ## Bugs BUG: if `setChoices` is not called on the ChoiceField, and the backing entity field is an Enum, the dropdown displays 0, 1, 2, 3, etc., because the `$choices` array ends up like this: ``` array:2 [ 0 => App\Enum\ProjectTypeEnum { +name: "PHP" +value: "php" } 1 => App\Enum\ProjectTypeEnum { +name: "DOCKER" +value: "docker" } ] ``` BUG: Symfony Forms attempts to convert the enum to string. ## Fixes ### Fix the ChoiceConfigurator This PR fixes the ChoiceConfigurator to behave as if `->setChoices(MyEnum::cases())` were called. Related to commit 65a422b of PR #5879 by `@SerheyDolgushev` ### Fix the forms Although closed, bug #5641 was not addressed by PR #5879. Without the change suggested by the original reported, the following errors are thrown: The EDIT action of a CRUD that contains a ChoiceField with an enum: `Object of class App\Enum\ProjectTypeEnum could not be converted to string` The Create action of a CRUD that contains a ChoiceField with an enum (the NEW page doesn't complain until submitted): `Expected argument of type "App\Enum\ProjectTypeEnum", "string" given at property path "type".` <!-- Thanks for your contribution! If you are proposing a new feature that is complex, please open an issue first so we can discuss about it. Note: all your contributions adhere implicitly to the MIT license --> Commits ------- 81175ac Updated ChoiceConfiguratorTest to work with the ChoiceConfigurator fixes 8774da3 Fix ChoiceConfigurator with enums a91ca47 Fix ChoiceField when entity is enumType and no choices have been given explicitly
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.