Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Console] Fixed SymfonyQuestionHelper multi-choice with defaults#19100
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| * Returns whether the choices are multiselect. | ||
| * | ||
| * @return bool | ||
| */ |
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.
Should beisMultiselect and i would add it right aftersetMultiselect
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.
Done
53a0c38 tobcb4f09Comparechalasr commentedJun 19, 2016
👍 (needs some tests). |
sstok commentedJun 20, 2016
Will add the test later today 👍 thanks for working on it. Status: Needs work |
bcb4f09 to0574adaComparesstok commentedJun 21, 2016
Tests added 👍 Status: Needs review |
chalasr commentedJun 21, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@sstok Your test fails on appveyor, the output is different than the expected one. Your test expects: "What is your favorite superhero? [Spiderman]" but the output is: It's because the SymfonyQuestionHelper decorates the output, disable it and tests should pass: - return new StreamOutput(fopen('php://memory', 'r+', false));+ $output = new StreamOutput(fopen('php://memory', 'r+', false));+ $output->setDecorated(false);++ return $output; |
ro0NL commentedJun 21, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Btw specifying defaults as |
sstok commentedJun 22, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
| $choices =$question->getChoices(); | ||
| $default =array_map('trim',explode(',',$default)); | ||
| foreach ($defaultas &$defaultVal) { |
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.
Can we avoid using references here?
foreach ($defaultas$key =>$value) {$default[$key] =$choices[$value];}
ro0NL commentedJun 22, 2016
@sstok understand, just wondered |
1637d7e to79815a9Comparesstok commentedJun 22, 2016
Squashed and rebased. |
fabpot commentedJun 22, 2016
Thank you@sstok. |
…faults (sstok)This PR was submitted for the 2.8 branch but it was merged into the 2.7 branch instead (closes#19100).Discussion----------[Console] Fixed SymfonyQuestionHelper multi-choice with defaults|Q |A ||--- |---||Bug Fix? |yes||New Feature? |no ||BC Breaks? |no ||Deprecations?|no ||Tests Pass? |yes||Fixed Tickets| ||License |MIT||Doc PR | |When you use the SymfonyStyle with a multi-choice question and multiple defaults.You get an notice because the key is used as-is `0,1` instead of splitting the value.This pull-request changes the SymfonyQuestionHelper to checks if the Choice is a multi-choiceand displays the selected values correctly `[blue, yellow]`.Note: Tests are missing, but both the SymfonyStyle and SymfonyQuestionHelper classeshave almost no tests. Making it really hard 😇 hopefully#19097 will make this easier 👍Commits-------a8f6f85 Fixed SymfonyQuestionHelper multi-choice with defaults
sstok commentedJun 28, 2016
@fabpot can you please merge the 2.7 up-to the master branch 👍 |
sstok commentedJun 29, 2016
Thanks ;) |

When you use the SymfonyStyle with a multi-choice question and multiple defaults.
You get an notice because the key is used as-is
0,1instead of splitting the value.This pull-request changes the SymfonyQuestionHelper to checks if the Choice is a multi-choice
and displays the selected values correctly
[blue, yellow].Note: Tests are missing, but both the SymfonyStyle and SymfonyQuestionHelper classes
have almost no tests. Making it really hard 😇 hopefully#19097 will make this easier 👍