-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Remove restriction for choices to be strings #34790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Console] Remove restriction for choices to be strings #34790
Conversation
Would be worth a test case, can you please add one? |
Friendly ping @LordZardeck |
I like this. Could you add a small test case so this can be merged? |
What is the pull request status? Do you need help? |
Anyone willing to take over this PR to finish it? @YaFou perhaps? |
I'm in vacation but I will finish it later @fabpot. Do I need to open a new pull request? |
You can push directly on this PR. |
I've tried to understand why we have the |
I'm fine for removing this cast. I think the original fix intended to make selecting choices indexed by keys consistent by always returning strings (it never meant to do it for choices sequentially indexed). A proper fix would have been either:
|
Thanks @ogizanagi. That's clearer to me now. @LordZardeck I think we need to add some test cases to cover the situation explained by @ogizanagi to be sure we don't break anything. |
These test cases already exist and are failing now, in Fixing the code to only cast in the case of assoc choices should solve everything here (we should not forget to get https://github.com/LordZardeck/symfony/pull/1 merged as well in here) |
@ogizanagi Would you like to take over? |
Sure, I'll update the PR this week |
to prevent inconsistency when choosing by key (getting a string as result) or by value (getting an int as result)
@fabpot : Done. But I'm wondering if this should not be merged as a bug fix into 3.4 since the cast was only meant for keys, not for values (int choices values were casted as well). Support for stringable objects just is a consequence of this fix. Let me know, I'll rebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a new feature to me. Master is fine :)
Thank you @LordZardeck. |
When using choice, selected answers are forced into strings, preventing us from using complex values such as a class with a custom __toString. This is a problem, as I need the ability to present the user with a list of display strings to choose from, but need the ID associated with that display string in order to do anything useful.