Skip to content

[Reference] field dependent empty_data option description #4033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions quick_tour/the_big_picture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ main concepts. Go to the following URL to be greeted by Symfony2 (replace
.. image:: /images/quick_tour/hello_fabien.png
:align: center

.. note::

Instead of the greeting page, you may see a blank page or an error page.
This is caused by a directory permission misconfiguration. There are several
possible solutions depending on your operating system. All of them are
explained in the :ref:`Setting up Permissions <book-installation-permissions>`
section of the official book.

What's going on here? Have a look at each part of the URL:

* ``app_dev.php``: This is a :term:`front controller`. It is the unique entry
Expand Down
10 changes: 10 additions & 0 deletions reference/forms/types/choice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ Overridden Options
------------------

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The actual default value of this option depends on other field options:

* If ``multiple`` is ``false`` and ``expanded`` is ``false``, then ``''``
(empty string);
* Otherwise ``array()`` (empty array).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

compound
~~~~~~~~
Expand Down
6 changes: 6 additions & 0 deletions reference/forms/types/collection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,12 @@ error_bubbling
.. include:: /reference/forms/types/options/by_reference.rst.inc

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The default value is ``array()`` (empty array).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down
10 changes: 10 additions & 0 deletions reference/forms/types/country.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ These options inherit from the :doc:`choice </reference/forms/types/choice>` typ
These options inherit from the :doc:`form </reference/forms/types/form>` type:

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The actual default value of this option depends on other field options:

* If ``multiple`` is ``false`` and ``expanded`` is ``false``, then ``''``
(empty string);
* Otherwise ``array()`` (empty array).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down
10 changes: 10 additions & 0 deletions reference/forms/types/currency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ These options inherit from the :doc:`choice</reference/forms/types/choice>` type
These options inherit from the :doc:`form</reference/forms/types/form>` type:

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The actual default value of this option depends on other field options:

* If ``multiple`` is ``false`` and ``expanded`` is ``false``, then ``''``
(empty string);
* Otherwise ``array()`` (empty array).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down
8 changes: 7 additions & 1 deletion reference/forms/types/email.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The ``email`` field is a text field that is rendered using the HTML5
| | - `error_mapping`_ |
| | - `mapped`_ |
+-------------+---------------------------------------------------------------------+
| Parent type | :doc:`form </reference/forms/types/form>` |
| Parent type | :doc:`text </reference/forms/types/text>` |
+-------------+---------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType` |
+-------------+---------------------------------------------------------------------+
Expand All @@ -36,6 +36,12 @@ These options inherit from the :doc:`form </reference/forms/types/form>` type:
.. include:: /reference/forms/types/options/max_length.rst.inc

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The default value is ``''`` (the empty string).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down
10 changes: 10 additions & 0 deletions reference/forms/types/entity.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ These options inherit from the :doc:`choice </reference/forms/types/choice>` typ
These options inherit from the :doc:`form </reference/forms/types/form>` type:

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The actual default value of this option depends on other field options:

* If ``multiple`` is ``false`` and ``expanded`` is ``false``, then ``''``
(empty string);
* Otherwise ``array()`` (empty array).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down
6 changes: 6 additions & 0 deletions reference/forms/types/file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ Inherited Options
These options inherit from the :doc:`form </reference/forms/types/form>` type:

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The default value is ``null``.

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down
12 changes: 12 additions & 0 deletions reference/forms/types/form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ Field Options
.. include:: /reference/forms/types/options/data_class.rst.inc

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The actual default value of this option depends on other field options:

* If ``data_class`` is set and ``required`` is ``true``, then ``new $data_class()``;
* If ``data_class`` is set and ``required`` is ``false``, then ``null``;
* If ``data_class`` is not set and ``compound`` is ``true``, then ``array()``
(empty array);
* If ``data_class`` is not set and ``compound`` is ``false``, then ``''`` (empty string).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/compound.rst.inc

Expand Down
6 changes: 6 additions & 0 deletions reference/forms/types/integer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ Inherited Options
These options inherit from the :doc:`form </reference/forms/types/form>` type:

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The default value is ``''`` (the empty string).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down
10 changes: 10 additions & 0 deletions reference/forms/types/language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ These options inherit from the :doc:`choice </reference/forms/types/choice>` typ
These options inherit from the :doc:`form </reference/forms/types/form>` type:

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The actual default value of this option depends on other field options:

* If ``multiple`` is ``false`` and ``expanded`` is ``false``, then ``''``
(empty string);
* Otherwise ``array()`` (empty array).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down
10 changes: 10 additions & 0 deletions reference/forms/types/locale.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ These options inherit from the :doc:`choice </reference/forms/types/choice>` typ
These options inherit from the :doc:`form </reference/forms/types/form>` type:

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The actual default value of this option depends on other field options:

* If ``multiple`` is ``false`` and ``expanded`` is ``false``, then ``''``
(empty string);
* Otherwise ``array()`` (empty array).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down
10 changes: 8 additions & 2 deletions reference/forms/types/money.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Specifies the currency that the money is being specified in. This determines
the currency symbol that should be shown by the text box. Depending on
the currency - the currency symbol may be shown before or after the input
text field.

This can be any `3 letter ISO 4217 code`_. You can also set this to false to
hide the currency symbol.

Expand Down Expand Up @@ -89,6 +89,12 @@ Inherited Options
These options inherit from the :doc:`form </reference/forms/types/form>` type:

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The default value is ``''`` (the empty string).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down Expand Up @@ -116,7 +122,7 @@ Form Variables
--------------

============= ========== ===============================================================
Variable Type Usage
Variable Type Usage
============= ========== ===============================================================
money_pattern ``string`` The format to use to display the money, including the currency.
============= ========== ===============================================================
Expand Down
8 changes: 7 additions & 1 deletion reference/forms/types/number.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ rounding_mode
If a submitted number needs to be rounded (based on the ``precision``
option), you have several configurable options for that rounding. Each
option is a constant on the :class:`Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\IntegerToLocalizedStringTransformer`:

* ``IntegerToLocalizedStringTransformer::ROUND_DOWN`` Rounding mode to
round towards zero.

Expand Down Expand Up @@ -79,6 +79,12 @@ Inherited Options
These options inherit from the :doc:`form </reference/forms/types/form>` type:

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The default value is ``''`` (the empty string).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down
5 changes: 2 additions & 3 deletions reference/forms/types/options/checkbox_empty_data.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ empty_data
**type**: ``string`` **default**: ``mixed``

This option determines what value the field will return when the ``empty_value``
choice is selected.
In checkbox, the value of ``empty_data`` is overriden by the value returned by
the data transformer (see :doc:`/cookbook/form/data_transformers`).
choice is selected. In the checkbox and the radio type, the value of ``empty_data``
is overriden by the value returned by the data transformer (see :doc:`/cookbook/form/data_transformers`).
15 changes: 4 additions & 11 deletions reference/forms/types/options/empty_data.rst.inc
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
empty_data
~~~~~~~~~~

**type**: ``mixed`` **default**: depends on other field options, see below
**type**: ``mixed``

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

The true default value of this option depends on other field options:
DEFAULT_PLACEHOLDER

* If ``data_class`` is set and ``required`` is ``true``, then ``new $data_class()``;
* If ``data_class`` is set and ``required`` is ``false``, then ``null``;
* If ``data_class`` is not set and ``compound`` is ``true``, then ``array()``;
* If ``data_class`` is not set and ``compound`` is ``false``, then ``''`` (empty string).
This option determines what value the field will return when the submitted
value is empty.

But you can customize this to your needs. For example, if you want the
``gender`` choice field to be explicitly set to ``null`` when no value is
Expand Down
6 changes: 6 additions & 0 deletions reference/forms/types/password.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ These options inherit from the :doc:`form </reference/forms/types/form>` type:
.. include:: /reference/forms/types/options/max_length.rst.inc

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The default value is ``''`` (the empty string).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down
6 changes: 6 additions & 0 deletions reference/forms/types/percent.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ Inherited Options
These options inherit from the :doc:`form </reference/forms/types/form>` type:

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The default value is ``''`` (the empty string).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/radio.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ These options inherit from the :doc:`form </reference/forms/types/form>` type:

.. include:: /reference/forms/types/options/data.rst.inc

.. include:: /reference/forms/types/options/empty_data.rst.inc
.. include:: /reference/forms/types/options/checkbox_empty_data.rst.inc

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down
6 changes: 6 additions & 0 deletions reference/forms/types/search.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ These options inherit from the :doc:`form </reference/forms/types/form>` type:
.. include:: /reference/forms/types/options/max_length.rst.inc

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The default value is ``''`` (the empty string).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down
6 changes: 6 additions & 0 deletions reference/forms/types/text.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ These options inherit from the :doc:`form </reference/forms/types/form>` type:
.. include:: /reference/forms/types/options/max_length.rst.inc

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The default value is ``''`` (the empty string).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down
8 changes: 7 additions & 1 deletion reference/forms/types/textarea.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Renders a ``textarea`` HTML element.
| | - `error_mapping`_ |
| | - `mapped`_ |
+-------------+------------------------------------------------------------------------+
| Parent type | :doc:`form </reference/forms/types/form>` |
| Parent type | :doc:`text </reference/forms/types/text>` |
+-------------+------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\TextareaType` |
+-------------+------------------------------------------------------------------------+
Expand All @@ -35,6 +35,12 @@ These options inherit from the :doc:`form </reference/forms/types/form>` type:
.. include:: /reference/forms/types/options/max_length.rst.inc

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The default value is ``''`` (the empty string).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down
10 changes: 10 additions & 0 deletions reference/forms/types/timezone.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ These options inherit from the :doc:`choice </reference/forms/types/choice>` typ
These options inherit from the :doc:`form </reference/forms/types/form>` type:

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The actual default value of this option depends on other field options:

* If ``multiple`` is ``false`` and ``expanded`` is ``false``, then ``''``
(empty string);
* Otherwise ``array()`` (empty array).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down
6 changes: 6 additions & 0 deletions reference/forms/types/url.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ These options inherit from the :doc:`form </reference/forms/types/form>` type:
.. include:: /reference/forms/types/options/max_length.rst.inc

.. include:: /reference/forms/types/options/empty_data.rst.inc
:end-before: DEFAULT_PLACEHOLDER

The default value is ``''`` (the empty string).

.. include:: /reference/forms/types/options/empty_data.rst.inc
:start-after: DEFAULT_PLACEHOLDER

.. include:: /reference/forms/types/options/required.rst.inc

Expand Down