Skip to content

Commit 907ed7e

Browse files
committed
Merge branch '6.4' into 7.1
* 6.4: Reword [Console] Adding associative array
2 parents 2a777ac + 53b7a44 commit 907ed7e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

components/console/helpers/questionhelper.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,28 @@ The option which should be selected by default is provided with the third
145145
argument of the constructor. The default is ``null``, which means that no
146146
option is the default one.
147147

148+
Choice questions display both the choice value and a numeric index, which starts
149+
from 0 by default. The user can type either the numeric index or the choice value
150+
to make a selection:
151+
152+
.. code-block:: terminal
153+
154+
Please select your favorite color (defaults to red):
155+
[0] red
156+
[1] blue
157+
[2] yellow
158+
>
159+
160+
.. tip::
161+
162+
To use custom indices, pass an array with custom numeric keys as the choice
163+
values::
164+
165+
new ChoiceQuestion('Select a room:', [
166+
102 => 'Room Foo',
167+
213 => 'Room Bar',
168+
]);
169+
148170
If the user enters an invalid string, an error message is shown and the user
149171
is asked to provide the answer another time, until they enter a valid string
150172
or reach the maximum number of attempts. The default value for the maximum number

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