Skip to content

Commit a1435e5

Browse files
committed
bug #3998 [Console] Fixed QuestionHelper examples (florianv)
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
2 parents ec832dc + 97c3894 commit a1435e5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

components/console/helpers/questionhelper.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ from a predefined list::
7777
$question = new ChoiceQuestion(
7878
'Please select your favorite color (defaults to red)',
7979
array('red', 'blue', 'yellow'),
80-
'red'
80+
0
8181
);
8282
$question->setErrorMessage('Color %s is invalid.');
8383

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

110110
$helper = $this->getHelper('question');
111111
$question = new ChoiceQuestion(
112-
'Please select your favorite color (defaults to red)',
112+
'Please select your favorite colors (defaults to red and blue)',
113113
array('red', 'blue', 'yellow'),
114-
'red'
114+
'0,1'
115115
);
116116
$question->setMultiselect(true);
117117

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

124+
If the user does not enter anything, the result will be:
125+
``You have just selected: red, blue``.
126+
124127
Autocompletion
125128
~~~~~~~~~~~~~~
126129

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy