From e76a40935f6651f85df8e9543fa8be9b394157d8 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 29 Jul 2019 16:56:07 +0200 Subject: [PATCH] [Form] Minor reword in the Choice type --- reference/forms/types/choice.rst | 5 +-- reference/forms/types/dateinterval.rst | 42 +++++++++++++++++++++----- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index 2f28c06016c..ea20f5b9af5 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -52,8 +52,9 @@ To use this field, you must specify *either* ``choices`` or ``choice_loader`` op Example Usage ------------- -The easiest way to use this field is to specify the choices directly via -the ``choices`` option:: +The easiest way to use this field is to define the ``choices`` option to specify +the choices as an associative array where the keys are the labels displayed to +end users and the array values are the internal values used in the form field:: use Symfony\Component\Form\Extension\Core\Type\ChoiceType; // ... diff --git a/reference/forms/types/dateinterval.rst b/reference/forms/types/dateinterval.rst index fae19648370..3e780148f8a 100644 --- a/reference/forms/types/dateinterval.rst +++ b/reference/forms/types/dateinterval.rst @@ -83,7 +83,11 @@ days List of days available to the days field type. This option is only relevant when the ``widget`` option is set to ``choice``:: - 'days' => range(1, 31) + // values displayed to users range from 0 to 30 (both inclusive) + 'days' => range(1, 31), + + // values displayed to users range from 1 to 31 (both inclusive) + 'days' => array_combine(range(1, 31), range(1, 31)), placeholder ~~~~~~~~~~~ @@ -112,7 +116,11 @@ hours List of hours available to the hours field type. This option is only relevant when the ``widget`` option is set to ``choice``:: - 'hours' => range(1, 24) + // values displayed to users range from 0 to 23 (both inclusive) + 'hours' => range(1, 24), + + // values displayed to users range from 1 to 24 (both inclusive) + 'hours' => array_combine(range(1, 24), range(1, 24)), input ~~~~~ @@ -161,7 +169,11 @@ minutes List of minutes available to the minutes field type. This option is only relevant when the ``widget`` option is set to ``choice``:: - 'minutes' => range(1, 60) + // values displayed to users range from 0 to 59 (both inclusive) + 'minutes' => range(1, 60), + + // values displayed to users range from 1 to 60 (both inclusive) + 'minutes' => array_combine(range(1, 60), range(1, 60)), months ~~~~~~ @@ -171,7 +183,11 @@ months List of months available to the months field type. This option is only relevant when the ``widget`` option is set to ``choice``:: - 'months' => range(1, 12) + // values displayed to users range from 0 to 11 (both inclusive) + 'months' => range(1, 12), + + // values displayed to users range from 1 to 12 (both inclusive) + 'months' => array_combine(range(1, 12), range(1, 12)), seconds ~~~~~~~ @@ -181,7 +197,11 @@ seconds List of seconds available to the seconds field type. This option is only relevant when the ``widget`` option is set to ``choice``:: - 'seconds' => range(1, 60) + // values displayed to users range from 0 to 59 (both inclusive) + 'seconds' => range(1, 60), + + // values displayed to users range from 1 to 60 (both inclusive) + 'seconds' => array_combine(range(1, 60), range(1, 60)), weeks ~~~~~ @@ -191,7 +211,11 @@ weeks List of weeks available to the weeks field type. This option is only relevant when the ``widget`` option is set to ``choice``:: - 'weeks' => range(1, 52) + // values displayed to users range from 0 to 51 (both inclusive) + 'weeks' => range(1, 52), + + // values displayed to users range from 1 to 52 (both inclusive) + 'weeks' => array_combine(range(1, 52), range(1, 52)), widget ~~~~~~ @@ -304,7 +328,11 @@ years List of years available to the years field type. This option is only relevant when the ``widget`` option is set to ``choice``:: - 'years' => range(1, 100) + // values displayed to users range from 0 to 99 (both inclusive) + 'years' => range(1, 100), + + // values displayed to users range from 1 to 100 (both inclusive) + 'years' => array_combine(range(1, 100), range(1, 100)), Inherited Options -----------------