Skip to content

[Console] ChoiceQuestion - choice to get value or key #51199

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

Open
wants to merge 1 commit into
base: 7.4
Choose a base branch
from

Conversation

maxbeckers
Copy link
Contributor

@maxbeckers maxbeckers commented Aug 1, 2023

Q A
Branch? 6.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #40439
License MIT
Doc PR symfony/symfony-docs#... TBD

Give the developer the Choice to get either the value(s) of a ChoiceQuestion (default behavior) or the key(s) of the selected values.

Example

$choices = ['value_0','value_1', 'value_2'];

$io = new SymfonyStyle($input, $output);

$value = $io->choice('Choose something', $choices, '1'); // $value would be 'value_1' with default choice
$key = $io->choice('Choose something', $choices, '1', true); // $key would be '1' with default choice

@maxbeckers maxbeckers requested a review from chalasr as a code owner August 1, 2023 06:38
@carsonbot carsonbot added this to the 6.4 milestone Aug 1, 2023
@maxbeckers maxbeckers force-pushed the patch-40439_choice_keys branch 4 times, most recently from 34638d8 to 6df429a Compare August 1, 2023 06:59
@maxbeckers maxbeckers force-pushed the patch-40439_choice_keys branch from 6df429a to b52e752 Compare August 1, 2023 07:03
@nicolas-grekas nicolas-grekas modified the milestones: 6.4, 7.1 Nov 15, 2023
@xabbuh xabbuh modified the milestones: 7.1, 7.2 May 15, 2024
@fabpot fabpot modified the milestones: 7.2, 7.3 Nov 20, 2024
@fabpot fabpot modified the milestones: 7.3, 7.4 May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SymfonyStyle ChoiceQuestion - choice to send value or key
5 participants