Skip to content

Commit ce3725b

Browse files
committed
minor #21071 [Console] Adding custom indices (ThomasLandauer)
This PR was merged into the 6.4 branch. Discussion ---------- [Console] Adding custom indices Page: https://symfony.com/doc/6.4/console/style.html#user-input-methods Wording is shortened from https://symfony.com/doc/current/components/console/helpers/questionhelper.html#let-the-user-choose-from-a-list-of-answers Commits ------- fb1931c [Console] Adding custom indices
2 parents 2e7b619 + fb1931c commit ce3725b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

console/style.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,11 @@ User Input Methods
327327

328328
$io->choice('Select the queue to analyze', ['queue1', 'queue2', 'queue3'], 'queue1');
329329

330+
Choice questions display both the choice value and a numeric index, which starts from 0
331+
by default. To use custom indices, pass an array with custom numeric keys as the choice values::
332+
333+
$io->choice('Select the queue to analyze', [5 => 'queue1', 6 => 'queue2', 7 => 'queue3']);
334+
330335
Finally, you can allow users to select multiple choices. To do so, users must
331336
separate each choice with a comma (e.g. typing ``1, 2`` will select choice 1
332337
and 2)::

0 commit comments

Comments
 (0)