Skip to content

Commit

Permalink
[Form] Deprecated max_length and pattern options
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefano Sala committed Apr 3, 2014
1 parent 974cb18 commit 456da28
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 16 deletions.
6 changes: 3 additions & 3 deletions book/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,8 @@ the correct values of a number of field options.
(i.e. is the field ``nullable``). This is very useful, as your client-side
validation will automatically match your validation rules.

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

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

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

.. index::
single: Forms; Rendering in a template
Expand Down
6 changes: 4 additions & 2 deletions reference/forms/twig_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,11 @@ object:
| ``required`` | If ``true``, a ``required`` attribute is added to the field to activate HTML5 |
| | validation. Additionally, a ``required`` class is added to the label. |
+------------------------+-------------------------------------------------------------------------------------+
| ``max_length`` | Adds a ``maxlength`` HTML attribute to the element. |
| ``max_length`` | Adds a ``maxlength`` HTML attribute to the element. (deprecated as of 2.5, to be |
| | removed in 3.0, use ``attr["maxlength"]`` instead) |
+------------------------+-------------------------------------------------------------------------------------+
| ``pattern`` | Adds a ``pattern`` HTML attribute to the element. |
| ``pattern`` | Adds a ``pattern`` HTML attribute to the element. (deprecated as of 2.5, to be |
| | removed in 3.0, use ``attr["pattern"]`` instead) |
+------------------------+-------------------------------------------------------------------------------------+
| ``label`` | The string label that will be rendered. |
+------------------------+-------------------------------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/email.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The ``email`` field is a text field that is rendered using the HTML5
+-------------+---------------------------------------------------------------------+
| Rendered as | ``input`` ``email`` field (a text box) |
+-------------+---------------------------------------------------------------------+
| Inherited | - `max_length`_ |
| Inherited | - `max_length`_ (deprecated as of 2.5) |
| options | - `empty_data`_ |
| | - `required`_ |
| | - `label`_ |
Expand Down
4 changes: 2 additions & 2 deletions reference/forms/types/form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on all types for which ``form`` is the parent type.
| | - `trim`_ |
| | - `mapped`_ |
| | - `property_path`_ |
| | - `max_length`_ |
| | - `max_length`_ (deprecated as of 2.5) |
| | - `by_reference`_ |
| | - `error_bubbling`_ |
| | - `inherit_data`_ |
Expand All @@ -29,7 +29,7 @@ on all types for which ``form`` is the parent type.
| | - `invalid_message_parameters`_ |
| | - `extra_fields_message`_ |
| | - `post_max_size_message`_ |
| | - `pattern`_ |
| | - `pattern`_ (deprecated as of 2.5) |
+-----------+--------------------------------------------------------------------+
| Inherited | - `block_name`_ |
| options | - `disabled`_ |
Expand Down
12 changes: 9 additions & 3 deletions reference/forms/types/options/max_length.rst.inc
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
.. caution::

The ``max_length`` option has been deprecated and will be removed in 3.0.
Instead, use the ``attr`` option by setting it to an array with a ``maxlength`` key.

max_length
~~~~~~~~~~

**type**: ``integer`` **default**: ``null``

If this option is not null, an attribute ``maxlength`` is added, which
is used by some browsers to limit the amount of text in a field.
If this option is not null, an attribute ``maxlength`` is added, which
is used by some browsers to limit the amount of text in a field.

This is just a browser validation, so data must still be validated
This is just a browser validation, so data must still be validated
server-side.

5 changes: 5 additions & 0 deletions reference/forms/types/options/pattern.rst.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.. caution::

The ``pattern`` option has been deprecated and will be removed in 3.0.
Instead, use the ``attr`` option by setting it to an array with a ``pattern`` key.

pattern
~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/password.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The ``password`` field renders an input password text box.
+-------------+------------------------------------------------------------------------+
| Options | - `always_empty`_ |
+-------------+------------------------------------------------------------------------+
| Inherited | - `max_length`_ |
| Inherited | - `max_length`_ (deprecated as of 2.5) |
| options | - `empty_data`_ |
| | - `required`_ |
| | - `label`_ |
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/search.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Read about the input search field at `DiveIntoHTML5.info`_
+-------------+----------------------------------------------------------------------+
| Rendered as | ``input search`` field |
+-------------+----------------------------------------------------------------------+
| Inherited | - `max_length`_ |
| Inherited | - `max_length`_ (deprecated as of 2.5) |
| options | - `empty_data`_ |
| | - `required`_ |
| | - `label`_ |
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/text.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The text field represents the most basic input text field.
+-------------+--------------------------------------------------------------------+
| Rendered as | ``input`` ``text`` field |
+-------------+--------------------------------------------------------------------+
| Inherited | - `max_length`_ |
| Inherited | - `max_length`_ (deprecated as of 2.5) |
| options | - `empty_data`_ |
| | - `required`_ |
| | - `label`_ |
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/textarea.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Renders a ``textarea`` HTML element.
+-------------+------------------------------------------------------------------------+
| Rendered as | ``textarea`` tag |
+-------------+------------------------------------------------------------------------+
| Inherited | - `max_length`_ |
| Inherited | - `max_length`_ (deprecated as of 2.5) |
| options | - `empty_data`_ |
| | - `required`_ |
| | - `label`_ |
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/url.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ have a protocol.
+-------------+-------------------------------------------------------------------+
| Options | - `default_protocol`_ |
+-------------+-------------------------------------------------------------------+
| Inherited | - `max_length`_ |
| Inherited | - `max_length`_ (deprecated as of 2.5) |
| options | - `empty_data`_ |
| | - `required`_ |
| | - `label`_ |
Expand Down

0 comments on commit 456da28

Please sign in to comment.