Skip to content

Documented the new date_label and time_label options #10389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions reference/forms/types/datetime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ the data can be a ``DateTime`` object, a string, a timestamp or an array.
+----------------------+-----------------------------------------------------------------------------+
| Options | - `choice_translation_domain`_ |
| | - `date_format`_ |
| | - `date_label`_ |
| | - `date_widget`_ |
| | - `days`_ |
| | - `placeholder`_ |
Expand All @@ -28,6 +29,7 @@ the data can be a ``DateTime`` object, a string, a timestamp or an array.
| | - `model_timezone`_ |
| | - `months`_ |
| | - `seconds`_ |
| | - `time_label`_ |
| | - `time_widget`_ |
| | - `view_timezone`_ |
| | - `widget`_ |
Expand Down Expand Up @@ -67,6 +69,23 @@ Defines the ``format`` option that will be passed down to the date field.
See the :ref:`DateType's format option <reference-forms-type-date-format>`
for more details.

date_label
~~~~~~~~~~

**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.

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;

$builder->add('startDateTime', DateTimeType::class, array(
'date_label' => 'Starts On',
));

date_widget
~~~~~~~~~~~

Expand Down Expand Up @@ -144,6 +163,23 @@ this format.

.. include:: /reference/forms/types/options/seconds.rst.inc

time_label
~~~~~~~~~~

**type**: ``string`` | ``null`` **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. Setting it to
``false`` will suppress the label::

use Symfony\Component\Form\Extension\Core\Type\DateTimeType;

$builder->add('startDateTime', DateTimeType::class, array(
'time_label' => 'Starts On',
));

time_widget
~~~~~~~~~~~

Expand Down