From fb1931c3cee0f598168b5c21d6bee54628dd2544 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Mon, 9 Jun 2025 23:25:24 +0200 Subject: [PATCH] [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 --- console/style.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/console/style.rst b/console/style.rst index bcc4d982457..9333409a13f 100644 --- a/console/style.rst +++ b/console/style.rst @@ -327,6 +327,11 @@ User Input Methods $io->choice('Select the queue to analyze', ['queue1', 'queue2', 'queue3'], 'queue1'); + Choice questions display both the choice value and a numeric index, which starts from 0 + by default. To use custom indices, pass an array with custom numeric keys as the choice values:: + + $io->choice('Select the queue to analyze', [5 => 'queue1', 6 => 'queue2', 7 => 'queue3']); + Finally, you can allow users to select multiple choices. To do so, users must separate each choice with a comma (e.g. typing ``1, 2`` will select choice 1 and 2)::