Skip to content

Commit

Permalink
Merge branch '7.1' into 7.2
Browse files Browse the repository at this point in the history
* 7.1:
  Reword
  [Console] Adding associative array
  • Loading branch information
javiereguiluz committed Jan 21, 2025
2 parents 326d46a + 907ed7e commit 8f874e1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions components/console/helpers/questionhelper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,28 @@ The option which should be selected by default is provided with the third
argument of the constructor. The default is ``null``, which means that no
option is the default one.

Choice questions display both the choice value and a numeric index, which starts
from 0 by default. The user can type either the numeric index or the choice value
to make a selection:

.. code-block:: terminal
Please select your favorite color (defaults to red):
[0] red
[1] blue
[2] yellow
>
.. tip::

To use custom indices, pass an array with custom numeric keys as the choice
values::

new ChoiceQuestion('Select a room:', [
102 => 'Room Foo',
213 => 'Room Bar',
]);

If the user enters an invalid string, an error message is shown and the user
is asked to provide the answer another time, until they enter a valid string
or reach the maximum number of attempts. The default value for the maximum number
Expand Down

0 comments on commit 8f874e1

Please sign in to comment.