Skip to content

Commit

Permalink
bug #3998 [Console] Fixed QuestionHelper examples (florianv)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.5 branch.

Discussion
----------

[Console] Fixed QuestionHelper examples

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | 2.5+
| Fixed tickets |

The default value corresponds to the index of the choice in the array, not it's name.

Commits
-------

97c3894 [Console] Fixed QuestionHelper examples
  • Loading branch information
weaverryan committed Jul 11, 2014
2 parents ec832dc + 97c3894 commit a1435e5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions components/console/helpers/questionhelper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ from a predefined list::
$question = new ChoiceQuestion(
'Please select your favorite color (defaults to red)',
array('red', 'blue', 'yellow'),
'red'
0
);
$question->setErrorMessage('Color %s is invalid.');

Expand Down Expand Up @@ -109,9 +109,9 @@ this use :method:`Symfony\\Component\\Console\\Question\\ChoiceQuestion::setMult

$helper = $this->getHelper('question');
$question = new ChoiceQuestion(
'Please select your favorite color (defaults to red)',
'Please select your favorite colors (defaults to red and blue)',
array('red', 'blue', 'yellow'),
'red'
'0,1'
);
$question->setMultiselect(true);

Expand All @@ -121,6 +121,9 @@ this use :method:`Symfony\\Component\\Console\\Question\\ChoiceQuestion::setMult
Now, when the user enters ``1,2``, the result will be:
``You have just selected: blue, yellow``.

If the user does not enter anything, the result will be:
``You have just selected: red, blue``.

Autocompletion
~~~~~~~~~~~~~~

Expand Down

0 comments on commit a1435e5

Please sign in to comment.