From 45bbc8c022c7a10706d5dfa8a51019edfc57f39a Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 24 Sep 2018 16:02:09 +0200 Subject: [PATCH 1/4] Documented the new date_label and time_label options --- reference/forms/types/datetime.rst | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/reference/forms/types/datetime.rst b/reference/forms/types/datetime.rst index 66f82abbc12..fbf15009e39 100644 --- a/reference/forms/types/datetime.rst +++ b/reference/forms/types/datetime.rst @@ -18,6 +18,7 @@ the data can be a ``DateTime`` object, a string, a timestamp or an array. | Options | - `choice_translation_domain`_ | | | - `date_format`_ | | | - `date_widget`_ | +| | - `date_label`_ | | | - `days`_ | | | - `placeholder`_ | | | - `format`_ | @@ -29,6 +30,7 @@ the data can be a ``DateTime`` object, a string, a timestamp or an array. | | - `months`_ | | | - `seconds`_ | | | - `time_widget`_ | +| | - `time_label`_ | | | - `view_timezone`_ | | | - `widget`_ | | | - `with_minutes`_ | @@ -72,6 +74,23 @@ date_widget .. include:: /reference/forms/types/options/date_widget_description.rst.inc +date_label +~~~~~~~~~~ + +**type**: ``string`` **default**: The label is "guessed" from the field name + +.. versionadded:: 4.2 + The ``date_label`` option was introduced in Symfony 4.2. + +Sets the label that will be used when rendering the date widget separately. +Setting to ``false`` will suppress the label:: + + use Symfony\Component\Form\Extension\Core\Type\DateTimeType; + + $builder->add('startDateTime', DateTimeType::class, array( + 'date_label' => 'Starts On', + )); + .. include:: /reference/forms/types/options/days.rst.inc placeholder @@ -151,6 +170,23 @@ time_widget Defines the ``widget`` option for the :doc:`TimeType `. +time_label +~~~~~~~~~~ + +**type**: ``string`` **default**: The label is "guessed" from the field name + +.. versionadded:: 4.2 + The ``time_label`` option was introduced in Symfony 4.2. + +Sets the label that will be used when rendering the time widget separately. +Setting to ``false`` will suppress the label:: + + use Symfony\Component\Form\Extension\Core\Type\DateTimeType; + + $builder->add('startDateTime', DateTimeType::class, array( + 'time_label' => 'Starts On', + )); + .. include:: /reference/forms/types/options/view_timezone.rst.inc widget From d098cd82c4dbc038e4bc1fb29127a9aa8f3f73c7 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 24 Sep 2018 16:04:10 +0200 Subject: [PATCH 2/4] Alloe null values too --- reference/forms/types/datetime.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/forms/types/datetime.rst b/reference/forms/types/datetime.rst index fbf15009e39..69960d93b8a 100644 --- a/reference/forms/types/datetime.rst +++ b/reference/forms/types/datetime.rst @@ -77,7 +77,7 @@ date_widget date_label ~~~~~~~~~~ -**type**: ``string`` **default**: The label is "guessed" from the field name +**type**: ``string`` | ``null`` **default**: The label is "guessed" from the field name .. versionadded:: 4.2 The ``date_label`` option was introduced in Symfony 4.2. @@ -173,7 +173,7 @@ Defines the ``widget`` option for the :doc:`TimeType Date: Tue, 25 Sep 2018 10:13:49 +0200 Subject: [PATCH 3/4] Fixes after the review --- reference/forms/types/datetime.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/reference/forms/types/datetime.rst b/reference/forms/types/datetime.rst index 69960d93b8a..c1607f5c0e3 100644 --- a/reference/forms/types/datetime.rst +++ b/reference/forms/types/datetime.rst @@ -17,8 +17,8 @@ the data can be a ``DateTime`` object, a string, a timestamp or an array. +----------------------+-----------------------------------------------------------------------------+ | Options | - `choice_translation_domain`_ | | | - `date_format`_ | -| | - `date_widget`_ | | | - `date_label`_ | +| | - `date_widget`_ | | | - `days`_ | | | - `placeholder`_ | | | - `format`_ | @@ -29,8 +29,8 @@ the data can be a ``DateTime`` object, a string, a timestamp or an array. | | - `model_timezone`_ | | | - `months`_ | | | - `seconds`_ | -| | - `time_widget`_ | | | - `time_label`_ | +| | - `time_widget`_ | | | - `view_timezone`_ | | | - `widget`_ | | | - `with_minutes`_ | @@ -82,8 +82,8 @@ date_label .. versionadded:: 4.2 The ``date_label`` option was introduced in Symfony 4.2. -Sets the label that will be used when rendering the date widget separately. -Setting to ``false`` will suppress the label:: +Sets the label that will be used when rendering the date widget. Setting it to +``false`` will suppress the label:: use Symfony\Component\Form\Extension\Core\Type\DateTimeType; @@ -178,8 +178,8 @@ time_label .. versionadded:: 4.2 The ``time_label`` option was introduced in Symfony 4.2. -Sets the label that will be used when rendering the time widget separately. -Setting to ``false`` will suppress the label:: +Sets the label that will be used when rendering the time widget. Setting it to +``false`` will suppress the label:: use Symfony\Component\Form\Extension\Core\Type\DateTimeType; From d47a894989e13dcef0c505a39306e63b5f895548 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 25 Sep 2018 13:22:53 +0200 Subject: [PATCH 4/4] Sorted the contents alphabetically too --- reference/forms/types/datetime.rst | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/reference/forms/types/datetime.rst b/reference/forms/types/datetime.rst index c1607f5c0e3..c18ac7cf524 100644 --- a/reference/forms/types/datetime.rst +++ b/reference/forms/types/datetime.rst @@ -69,11 +69,6 @@ Defines the ``format`` option that will be passed down to the date field. See the :ref:`DateType's format option ` for more details. -date_widget -~~~~~~~~~~~ - -.. include:: /reference/forms/types/options/date_widget_description.rst.inc - date_label ~~~~~~~~~~ @@ -91,6 +86,11 @@ Sets the label that will be used when rendering the date widget. Setting it to 'date_label' => 'Starts On', )); +date_widget +~~~~~~~~~~~ + +.. include:: /reference/forms/types/options/date_widget_description.rst.inc + .. include:: /reference/forms/types/options/days.rst.inc placeholder @@ -163,13 +163,6 @@ this format. .. include:: /reference/forms/types/options/seconds.rst.inc -time_widget -~~~~~~~~~~~ - -**type**: ``string`` **default**: ``choice`` - -Defines the ``widget`` option for the :doc:`TimeType `. - time_label ~~~~~~~~~~ @@ -187,6 +180,13 @@ Sets the label that will be used when rendering the time widget. Setting it to 'time_label' => 'Starts On', )); +time_widget +~~~~~~~~~~~ + +**type**: ``string`` **default**: ``choice`` + +Defines the ``widget`` option for the :doc:`TimeType `. + .. include:: /reference/forms/types/options/view_timezone.rst.inc widget