Skip to content

Commit dc22276

Browse files
committed
[Reference][Form Types] Add missing (but existing) form options to "form"
type
1 parent 42c80d1 commit dc22276

File tree

5 files changed

+37
-25
lines changed

5 files changed

+37
-25
lines changed

reference/forms/types/form.rst

+12-3
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,17 @@ on all fields.
4545

4646
.. include:: /reference/forms/types/options/max_length.rst.inc
4747

48-
inherit_data
49-
------------
48+
.. include:: /reference/forms/types/options/empty_data.rst.inc
49+
50+
.. include:: /reference/forms/types/options/by_reference.rst.inc
51+
52+
.. include:: /reference/forms/types/options/error_bubbling.rst.inc
53+
54+
.. include:: /reference/forms/types/options/inherit_data.rst.inc
55+
56+
.. include:: /reference/forms/types/options/error_mapping.rst.inc
57+
58+
.. include:: /reference/forms/types/options/invalid_message.rst.inc
5059

51-
See :doc:`/cookbook/form/inherit_data_option`.
60+
.. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc
5261

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
If true, any errors for this field will be passed to the parent field
2-
or form. For example, if set to true on a normal field, any errors for
1+
If ``true``, any errors for this field will be passed to the parent field
2+
or form. For example, if set to ``true`` on a normal field, any errors for
33
that field will be attached to the main form, not to the specific field.

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ by_reference
33

44
**type**: ``Boolean`` **default**: ``true``
55

6-
In most cases, if you have a ``name`` field, then you expect ``setName``
7-
to be called on the underlying object. In some cases, however, ``setName``
6+
In most cases, if you have a ``name`` field, then you expect ``setName()``
7+
to be called on the underlying object. In some cases, however, ``setName()``
88
may *not* be called. Setting ``by_reference`` ensures that the setter is
99
called in all cases.
1010

@@ -20,13 +20,13 @@ To explain this further, here's a simple example::
2020
)
2121

2222
If ``by_reference`` is true, the following takes place behind the scenes
23-
when you call ``submit`` (or ``handleRequest``) on the form::
23+
when you call ``submit()`` (or ``handleRequest()``) on the form::
2424

2525
$article->setTitle('...');
2626
$article->getAuthor()->setName('...');
2727
$article->getAuthor()->setEmail('...');
2828

29-
Notice that ``setAuthor`` is not called. The author is modified by reference.
29+
Notice that ``setAuthor()`` is not called. The author is modified by reference.
3030

3131
If you set ``by_reference`` to false, submitting looks like this::
3232

@@ -42,4 +42,4 @@ call the setter on the parent object.
4242
Similarly, if you're using the :doc:`collection</reference/forms/types/collection>`
4343
form type where your underlying collection data is an object (like with Doctrine's
4444
``ArrayCollection``), then ``by_reference`` must be set to ``false`` if you
45-
need the setter (e.g. ``setAuthors``) to be called.
45+
need the setter (e.g. ``setAuthors()``) to be called.

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

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
empty_data
22
~~~~~~~~~~
33

4-
**type**: ``mixed`` **default**: ``array()`` if ``multiple`` or ``expanded``, ``''`` otherwise
4+
**type**: ``mixed`` **default**: depends on other field options, see below
55

6-
This option determines what value the field will return when the ``empty_value``
7-
choice is selected.
6+
This option determines what value the field will return when the submitted
7+
value is empty. This may happen when the ``empty_value`` choice in a
8+
``choice`` field is selected or when an ``input`` field of some type is not
9+
required and left empty by the user.
810

9-
The true default value of this option depends on the field options:
11+
The true default value of this option depends on other field options:
1012

11-
* If ``data_class`` is set and ``required`` is ``true``, then ``new $data_class()``;
12-
* If ``data_class`` is set and ``required`` is ``false``, then ``null``;
13-
* If ``data_class`` is not set and ``compound`` is ``true``, then ``array()``;
14-
* If ``data_class`` is not set and ``compound`` is ``false``, then ``null``.
13+
* If ``data_class`` is set and ``required`` is ``true``, then ``new $data_class()``;
14+
* If ``data_class`` is set and ``required`` is ``false``, then ``null``;
15+
* If ``data_class`` is not set and ``compound`` is ``true``, then ``array()``;
16+
* If ``data_class`` is not set and ``compound`` is ``false``, then ``''`` (empty string).
1517

16-
But you can customize this to your needs. For example, if you want the ``gender`` field to be
17-
explicitly set to ``null`` when no value is selected, you can do it like this:
18+
But you can customize this to your needs. For example, if you want the
19+
``gender`` choice field to be explicitly set to ``null`` when no value is
20+
selected, you can do it like this:
1821

1922
.. code-block:: php
2023

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ field so that it displays above it::
2727

2828
Here are the rules for the left and the right side of the mapping:
2929

30-
* The left side contains property paths.
30+
* The left side contains property paths;
3131
* If the violation is generated on a property or method of a class, its path
32-
is simply "propertyName".
32+
is simply ``propertyName``;
3333
* If the violation is generated on an entry of an ``array`` or ``ArrayAccess``
34-
object, the property path is ``[indexName]``.
34+
object, the property path is ``[indexName]``;
3535
* You can construct nested property paths by concatenating them, separating
36-
properties by dots. For example: ``addresses[work].matchingCityAndZipCode``
36+
properties by dots. For example: ``addresses[work].matchingCityAndZipCode``;
3737
* The left side of the error mapping also accepts a dot ``.``, which refers
3838
to the field itself. That means that any error added to the field is added
39-
to the given nested field instead.
39+
to the given nested field instead;
4040
* The right side contains simply the names of fields in the form.

0 commit comments

Comments
 (0)