Skip to content

Commit 78faf26

Browse files
committed
minor symfony#10882 [Form] Add input_format option to DateType, DateTimeType and TimeType (fancyweb)
This PR was squashed before being merged into the master branch (closes symfony#10882). Discussion ---------- [Form] Add input_format option to DateType, DateTimeType and TimeType Related Symfony PRs : symfony/symfony#29887 and symfony/symfony#30358 Commits ------- 8fc1b53 [Form] Add input_format option to DateType, DateTimeType and TimeType
2 parents 799b998 + 8fc1b53 commit 78faf26

File tree

6 files changed

+43
-0
lines changed

6 files changed

+43
-0
lines changed

reference/forms/types/birthday.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ option defaults to 120 years ago to the current year.
2929
| | - `placeholder`_ |
3030
| | - `format`_ |
3131
| | - `input`_ |
32+
| | - `input_format`_ |
3233
| | - `model_timezone`_ |
3334
| | - `months`_ |
3435
| | - `view_timezone`_ |
@@ -99,6 +100,8 @@ values for the year, month and day fields::
99100

100101
.. include:: /reference/forms/types/options/date_input.rst.inc
101102

103+
.. include:: /reference/forms/types/options/date_input_format.rst.inc
104+
102105
.. include:: /reference/forms/types/options/model_timezone.rst.inc
103106

104107
.. include:: /reference/forms/types/options/months.rst.inc

reference/forms/types/date.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and can understand a number of different input formats via the `input`_ option.
2121
| | - `format`_ |
2222
| | - `html5`_ |
2323
| | - `input`_ |
24+
| | - `input_format`_ |
2425
| | - `model_timezone`_ |
2526
| | - `months`_ |
2627
| | - `view_timezone`_ |
@@ -181,6 +182,8 @@ values for the year, month and day fields::
181182

182183
.. include:: /reference/forms/types/options/date_input.rst.inc
183184

185+
.. include:: /reference/forms/types/options/date_input_format.rst.inc
186+
184187
.. include:: /reference/forms/types/options/model_timezone.rst.inc
185188

186189
.. include:: /reference/forms/types/options/months.rst.inc

reference/forms/types/datetime.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ the data can be a ``DateTime`` object, a string, a timestamp or an array.
2525
| | - `hours`_ |
2626
| | - `html5`_ |
2727
| | - `input`_ |
28+
| | - `input_format`_ |
2829
| | - `minutes`_ |
2930
| | - `model_timezone`_ |
3031
| | - `months`_ |
@@ -166,6 +167,13 @@ this format.
166167

167168
.. include:: /reference/forms/types/options/_date_limitation.rst.inc
168169

170+
input_format
171+
~~~~~~~~~~~~
172+
173+
**type**: ``string`` **default**: ``Y-m-d H:i:s``
174+
175+
.. include:: /reference/forms/types/options/date_input_format_description.rst.inc
176+
169177
.. include:: /reference/forms/types/options/minutes.rst.inc
170178

171179
.. include:: /reference/forms/types/options/model_timezone.rst.inc
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
input_format
2+
~~~~~~~~~~~~
3+
4+
**type**: ``string`` **default**: ``Y-m-d``
5+
6+
.. include:: /reference/forms/types/options/date_input_format_description.rst.inc
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. versionadded:: 4.3
2+
3+
The ``input_format`` option was introduced in Symfony 4.3.
4+
5+
If the ``input`` option is set to ``string``, this option specifies the format
6+
of the date. This must be a valid `PHP date format`_.
7+
8+
.. _`PHP date format`: https://secure.php.net/manual/en/function.date.php

reference/forms/types/time.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ stored as a ``DateTime`` object, a string, a timestamp or an array.
2020
| | - `hours`_ |
2121
| | - `html5`_ |
2222
| | - `input`_ |
23+
| | - `input_format`_ |
2324
| | - `minutes`_ |
2425
| | - `model_timezone`_ |
2526
| | - `seconds`_ |
@@ -131,6 +132,18 @@ on your underlying object. Valid values are:
131132
The value that comes back from the form will also be normalized back into
132133
this format.
133134

135+
input_format
136+
~~~~~~~~~~~~
137+
138+
**type**: ``string`` **default**: ``H:i:s``
139+
140+
.. versionadded:: 4.3
141+
142+
The ``input_format`` option was introduced in Symfony 4.3.
143+
144+
If the ``input`` option is set to ``string``, this option specifies the format
145+
of the time. This must be a valid `PHP time format`_.
146+
134147
.. include:: /reference/forms/types/options/minutes.rst.inc
135148

136149
.. include:: /reference/forms/types/options/model_timezone.rst.inc
@@ -226,3 +239,5 @@ Form Variables
226239
| type | ``string`` | Only present when widget is ``single_text`` and HTML5 is activated, |
227240
| | | contains the input type to use (``datetime``, ``date`` or ``time``). |
228241
+--------------+-------------+----------------------------------------------------------------------+
242+
243+
.. _`PHP time format`: https://secure.php.net/manual/en/function.date.php

0 commit comments

Comments
 (0)