8000 minor #19105 [Console] [Question helper] Add more accuracy from a li… · symfony/symfony-docs@ffe66c4 · GitHub
[go: up one dir, main page]

Skip to content

Commit ffe66c4

Browse files
committed
minor #19105 [Console] [Question helper] Add more accuracy from a list of answers (devojifr)
This PR was merged into the 5.4 branch. Discussion ---------- [Console] [Question helper] Add more accuracy from a list of answers User can select its choice by string or indexed answer from the list. The default value can be a string or the indexed answer. Commits ------- 4d6e960 [Question helper] Add more accuracy from a list of answers
2 parents 7f1fc9c + 4d6e960 commit ffe66c4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

components/console/helpers/questionhelper.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ Let the User Choose from a List of Answers
113113

114114
If you have a predefined set of answers the user can choose from, you
115115
could use a :class:`Symfony\\Component\\Console\\Question\\ChoiceQuestion`
116-
which makes sure that the user can only enter a valid string
117-
from a predefined list::
116+
which makes sure that the user can only enter a valid string or the index
117+
of the choice from a predefined list. In the example below, typing ``blue``
118+
or ``1`` is the same choice for the user. A default value is set with ``0``
119+
but ``red`` could be set instead (could be more explicit)::
118120

119121
use Symfony\Component\Console\Question\ChoiceQuestion;
120122

0 commit comments

Comments
 (0)
0