-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] invalid default returned from ChoiceQuestion on non interactive mode when using SymfonyStyle #25470
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
Comments
@mathroc Could you make a PR for this ? I think this should be a bugfix since the behaviour is wrong right now. |
Can you give a simple reproducer so that we can confirm it's a bug? |
@chalasr Reproducer and bugfix added. |
Status: Reviewed |
nicolas-grekas
added a commit
that referenced
this issue
Dec 18, 2017
…nd passing -n would output the index (Simperfit) This PR was merged into the 2.7 branch. Discussion ---------- [Console] fix a bug when you are passing a default value and passing -n would output the index | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | #25470 | License | MIT | Doc PR | We are fixing a bug when you are using a default value with -n, it would output the index instead of the value. Simple reproducer Simperfit/symfony-reproducer@5079dd1?diff=split#diff-77efcc28bc5309e1af9ac07a1e073009R40 Commits ------- 41ffc69 [Console] fix a bug when you are passing a default value and passing -n would ouput the index
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the choice index is returned instead of the choice value when a default choice is specified and the command is executed with
-n
the default value is set to the choice index here : https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Style/SymfonyStyle.php#L230
so I’ve tried to run
$io->askQuestion(new ChoiceQuestion($question, $choices, $default));
directly. it works on non interactive mode but fails on interactive modeI think
ChoiceQuestion
should overridegetDefault()
to solve this. I can make a PR for this but will this considered a BC break ? or does it falls in the bug fix category ?The text was updated successfully, but these errors were encountered: