Skip to content

Commit 456da28

Browse files
author
Stefano Sala
committed
[Form] Deprecated max_length and pattern options
1 parent 974cb18 commit 456da28

11 files changed

+29
-16
lines changed

book/forms.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,8 @@ the correct values of a number of field options.
707707
(i.e. is the field ``nullable``). This is very useful, as your client-side
708708
validation will automatically match your validation rules.
709709

710-
* ``max_length``: If the field is some sort of text field, then the ``max_length``
711-
option can be guessed from the validation constraints (if ``Length`` or
710+
* ``maxlength``: If the field is some sort of text field, then the ``maxlength``
711+
option attribute can be guessed from the validation constraints (if ``Length`` or
712712
``Range`` is used) or from the Doctrine metadata (via the field's length).
713713

714714
.. note::
@@ -719,7 +719,7 @@ the correct values of a number of field options.
719719
If you'd like to change one of the guessed values, you can override it by
720720
passing the option in the options field array::
721721

722-
->add('task', null, array('max_length' => 4))
722+
->add('task', null, array('attr' => array('maxlength' => 4)))
723723

724724
.. index::
725725
single: Forms; Rendering in a template

reference/forms/twig_reference.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,11 @@ object:
350350
| ``required`` | If ``true``, a ``required`` attribute is added to the field to activate HTML5 |
351351
| | validation. Additionally, a ``required`` class is added to the label. |
352352
+------------------------+-------------------------------------------------------------------------------------+
353-
| ``max_length`` | Adds a ``maxlength`` HTML attribute to the element. |
353+
| ``max_length`` | Adds a ``maxlength`` HTML attribute to the element. (deprecated as of 2.5, to be |
354+
| | removed in 3.0, use ``attr["maxlength"]`` instead) |
354355
+------------------------+-------------------------------------------------------------------------------------+
355-
| ``pattern`` | Adds a ``pattern`` HTML attribute to the element. |
356+
| ``pattern`` | Adds a ``pattern`` HTML attribute to the element. (deprecated as of 2.5, to be |
357+
| | removed in 3.0, use ``attr["pattern"]`` instead) |
356358
+------------------------+-------------------------------------------------------------------------------------+
357359
| ``label`` | The string label that will be rendered. |
358360
+------------------------+-------------------------------------------------------------------------------------+

reference/forms/types/email.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The ``email`` field is a text field that is rendered using the HTML5
1010
+-------------+---------------------------------------------------------------------+
1111
| Rendered as | ``input`` ``email`` field (a text box) |
1212
+-------------+---------------------------------------------------------------------+
13-
| Inherited | - `max_length`_ |
13+
| Inherited | - `max_length`_ (deprecated as of 2.5) |
1414
| options | - `empty_data`_ |
1515
| | - `required`_ |
1616
| | - `label`_ |

reference/forms/types/form.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on all types for which ``form`` is the parent type.
2020
| | - `trim`_ |
2121
| | - `mapped`_ |
2222
| | - `property_path`_ |
23-
| | - `max_length`_ |
23+
| | - `max_length`_ (deprecated as of 2.5) |
2424
| | - `by_reference`_ |
2525
| | - `error_bubbling`_ |
2626
| | - `inherit_data`_ |
@@ -29,7 +29,7 @@ on all types for which ``form`` is the parent type.
2929
| | - `invalid_message_parameters`_ |
3030
| | - `extra_fields_message`_ |
3131
| | - `post_max_size_message`_ |
32-
| | - `pattern`_ |
32+
| | - `pattern`_ (deprecated as of 2.5) |
3333
+-----------+--------------------------------------------------------------------+
3434
| Inherited | - `block_name`_ |
3535
| options | - `disabled`_ |
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
.. caution::
2+
3+
The ``max_length`` option has been deprecated and will be removed in 3.0.
4+
Instead, use the ``attr`` option by setting it to an array with a ``maxlength`` key.
5+
16
max_length
27
~~~~~~~~~~
38

49
**type**: ``integer`` **default**: ``null``
510

6-
If this option is not null, an attribute ``maxlength`` is added, which
7-
is used by some browsers to limit the amount of text in a field.
11+
If this option is not null, an attribute ``maxlength`` is added, which
12+
is used by some browsers to limit the amount of text in a field.
813

9-
This is just a browser validation, so data must still be validated
14+
This is just a browser validation, so data must still be validated
1015
server-side.
16+

reference/forms/types/options/pattern.rst.inc

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
.. caution::
2+
3+
The ``pattern`` option has been deprecated and will be removed in 3.0.
4+
Instead, use the ``attr`` option by setting it to an array with a ``pattern`` key.
5+
16
pattern
27
~~~~~~~
38

reference/forms/types/password.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The ``password`` field renders an input password text box.
1111
+-------------+------------------------------------------------------------------------+
1212
| Options | - `always_empty`_ |
1313
+-------------+------------------------------------------------------------------------+
14-
| Inherited | - `max_length`_ |
14+
| Inherited | - `max_length`_ (deprecated as of 2.5) |
1515
| options | - `empty_data`_ |
1616
| | - `required`_ |
1717
| | - `label`_ |

reference/forms/types/search.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Read about the input search field at `DiveIntoHTML5.info`_
1212
+-------------+----------------------------------------------------------------------+
1313
| Rendered as | ``input search`` field |
1414
+-------------+----------------------------------------------------------------------+
15-
| Inherited | - `max_length`_ |
15+
| Inherited | - `max_length`_ (deprecated as of 2.5) |
1616
| options | - `empty_data`_ |
1717
| | - `required`_ |
1818
| | - `label`_ |

reference/forms/types/text.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The text field represents the most basic input text field.
99
+-------------+--------------------------------------------------------------------+
1010
| Rendered as | ``input`` ``text`` field |
1111
+-------------+--------------------------------------------------------------------+
12-
| Inherited | - `max_length`_ |
12+
| Inherited | - `max_length`_ (deprecated as of 2.5) |
1313
| options | - `empty_data`_ |
1414
| | - `required`_ |
1515
| | - `label`_ |

reference/forms/types/textarea.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Renders a ``textarea`` HTML element.
99
+-------------+------------------------------------------------------------------------+
1010
| Rendered as | ``textarea`` tag |
1111
+-------------+------------------------------------------------------------------------+
12-
| Inherited | - `max_length`_ |
12+
| Inherited | - `max_length`_ (deprecated as of 2.5) |
1313
| options | - `empty_data`_ |
1414
| | - `required`_ |
1515
| | - `label`_ |

reference/forms/types/url.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ have a protocol.
1313
+-------------+-------------------------------------------------------------------+
1414
| Options | - `default_protocol`_ |
1515
+-------------+-------------------------------------------------------------------+
16-
| Inherited | - `max_length`_ |
16+
| Inherited | - `max_length`_ (deprecated as of 2.5) |
1717
| options | - `empty_data`_ |
1818
| | - `required`_ |
1919
| | - `label`_ |

0 commit comments

Comments
 (0)