Closed
Description
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".