Skip to content

Commit 8fc1b53

Browse files
fancywebjaviereguiluz
authored andcommitted
[Form] Add input_format option to DateType, DateTimeType and TimeType
1 parent f760075 commit 8fc1b53

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`_ |
@@ -96,6 +97,8 @@ values for the year, month and day fields::
9697

9798
.. include:: /reference/forms/types/options/date_input.rst.inc
9899

100+
.. include:: /reference/forms/types/options/date_input_format.rst.inc
101+
99102
.. include:: /reference/forms/types/options/model_timezone.rst.inc
100103

101104
.. 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`_ |
@@ -168,6 +169,8 @@ values for the year, month and day fields::
168169

169170
.. include:: /reference/forms/types/options/date_input.rst.inc
170171

172+
.. include:: /reference/forms/types/options/date_input_format.rst.inc
173+
171174
.. include:: /reference/forms/types/options/model_timezone.rst.inc
172175

173176
.. 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`_ |
@@ -153,6 +154,13 @@ this format.
153154

154155
.. include:: /reference/forms/types/options/_date_limitation.rst.inc
155156

157+
input_format
158+
~~~~~~~~~~~~
159+
160+
**type**: ``string`` **default**: ``Y-m-d H:i:s``
161+
162+
.. include:: /reference/forms/types/options/date_input_format_description.rst.inc
163+
156164
.. include:: /reference/forms/types/options/minutes.rst.inc
157165

158166
.. 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`_ |
@@ -129,6 +130,18 @@ on your underlying object. Valid values are:
129130
The value that comes back from the form will also be normalized back into
130131
this format.
131132

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

134147
.. include:: /reference/forms/types/options/model_timezone.rst.inc
@@ -222,3 +235,5 @@ Form Variables
222235
| type | ``string`` | Only present when widget is ``single_text`` and HTML5 is activated, |
223236
| | | contains the input type to use (``datetime``, ``date`` or ``time``). |
224237
+--------------+-------------+----------------------------------------------------------------------+
238+
239+
.. _`PHP time format`: https://secure.php.net/manual/en/function.date.php

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy