Skip to content

Update dialog helper docs to add 2.3 features #2571

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

Closed
wouterj opened this issue Apr 29, 2013 · 1 comment
Closed

Update dialog helper docs to add 2.3 features #2571

wouterj opened this issue Apr 29, 2013 · 1 comment
Labels
actionable Clear and specific issues ready for anyone to take them. Console good first issue Ideal for your first contribution! (some Symfony experience may be required)
Milestone

Comments

@wouterj
Copy link
Member

wouterj commented Apr 29, 2013

As of 2.3, the DialogHelper::select method accepts multiselect by using comma seperated values:

$dialog = $app->getHelperSet()->get('dialog');
$colors = array('red', 'blue', 'yellow');

$selected = $dialog->select(
    $output,
    'Please select your favorite color (default to red)',
    $colors,
    0,
    false,
    'Value "%s" is invalid',
    true // multiselect support is disabled by default
);

$selectedColors = array_map(funtion($c) use ($colors) {
    return $colors[$c];
}, $selected)

$output->writeln('You have just selected: ' . implode(', ', $selectedColors));

Now, when a user inputs 1,2, the result will be "You have just selected: blue, yellow".

@wouterj
Copy link
Member Author

wouterj commented Apr 29, 2013

related PR: symfony/symfony#7602

wouterj added a commit to wouterj/symfony-docs that referenced this issue May 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Clear and specific issues ready for anyone to take them. Console good first issue Ideal for your first contribution! (some Symfony experience may be required)
Projects
None yet
Development

No branches or pull requests

2 participants