Skip to content

[DialogHelper] Multiselect : added an option to the "select" function that makes the possibility of multiselect options. #7602

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
wants to merge 7 commits into from

Conversation

quiqueporta
Copy link
Contributor

When the option list appears, you can select more than one value separated by comma.

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

*
* @throws \InvalidArgumentException
*/
public function select(OutputInterface $output, $question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid')
public function select(OutputInterface $output, $question, $choices, $default = null, $attempts = false, $multiselect = false, $errorMessage = 'Value "%s" is invalid')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the parameter in the middle of the signature is a BC break

@fabpot
Copy link
Member

fabpot commented Apr 11, 2013

Can you take @stof comments into account?

@quiqueporta
Copy link
Contributor Author

of course, I'm working on it.
I've had a hard week: P

@stof
Copy link
Member

stof commented Apr 11, 2013

@quiqueporta Please also update the PR description with the PR summary

@quiqueporta
Copy link
Contributor Author

OK, thanks ;)
sorry for the mistake
it's my first PR

Fixed the function returns.
Fixed the Test
@quiqueporta
Copy link
Contributor Author

@stof now the multiselect option return an array of key => value.

$colors = ['red','blue','orange'];

// Make the select with multiselect option true.
// and select 0,2 options.

// The select returns this ...
Array
(
    [0] => 'red'
    [2] => 'orange'
)

Would it be better to return only the keys?

$colors = ['red','blue','orange'];

// Make the select with multiselect option true.
// and select 0,2 options.

// The select returns this ...

Array
(
    [0] => 0
    [1] => 2
)

@stof
Copy link
Member

stof commented Apr 13, 2013

it should indeed return keys to be consistent with the behavior of the non-multiple version

@quiqueporta
Copy link
Contributor Author

Ok, i will make the modification and push it ;)

@quiqueporta
Copy link
Contributor Author

@stof , ok i make the modificacions ;)

if (empty($choices[$picked])) {
throw new \InvalidArgumentException(sprintf($errorMessage, $picked));
$result = $this->askAndValidate($output, '> ', function ($picked) use ($choices, $errorMessage, $multiselect) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this blank line should be removed.

@quiqueporta
Copy link
Contributor Author

Yes to all

throw new \InvalidArgumentException(sprintf($errorMessage, $picked));
$result = $this->askAndValidate($output, '> ', function ($picked) use ($choices, $errorMessage, $multiselect) {
// Collapse all spaces.
$selectedChoices = str_replace(" ","", $picked);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need spaces before "" for CS?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, good catch.

@quiqueporta quiqueporta deleted the multiselect branch May 27, 2013 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants