Skip to content

Commit

Permalink
Reviewed form type options includes
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed May 23, 2015
1 parent ffe2b15 commit 03fdc5b
Show file tree
Hide file tree
Showing 30 changed files with 105 additions and 92 deletions.
8 changes: 4 additions & 4 deletions reference/forms/types/options/action.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ action

**type**: ``string`` **default**: empty string

This option specifies where to send the form's data on submission (usually a
URI). Its value is rendered as the ``action`` attribute of the ``form``
element. An empty value is considered a same-document reference, i.e. the form
will be submitted to the same URI that rendered the form.
This option specifies where to send the form's data on submission (usually
a URI). Its value is rendered as the ``action`` attribute of the ``form``
element. An empty value is considered a same-document reference, i.e. the
form will be submitted to the same URI that rendered the form.
5 changes: 3 additions & 2 deletions reference/forms/types/options/auto_initialize.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ auto_initialize
**type**: ``boolean`` **default**: ``true``

An internal option: sets whether the form should be initialized automatically.
For all fields, this option should only be ``true`` for root forms. You won't
need to change this option and probably won't need to worry about it.
For all fields, this option should only be ``true`` for root forms. You
won't need to change this option and probably won't need to worry about
it.
2 changes: 1 addition & 1 deletion reference/forms/types/options/block_name.rst.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
block_name
~~~~~~~~~~~
~~~~~~~~~~

**type**: ``string`` **default**: the form's name (see :ref:`Knowing which
block to customize <cookbook-form-customization-sidebar>`)
Expand Down
4 changes: 2 additions & 2 deletions reference/forms/types/options/button_label.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ label

**type**: ``string`` **default**: The label is "guessed" from the field name

Sets the label that will be displayed on the button. The label can also be
directly set inside the template:
Sets the label that will be displayed on the button. The label can also
be directly set inside the template:

.. configuration-block::

Expand Down
7 changes: 4 additions & 3 deletions reference/forms/types/options/by_reference.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ So, all that ``by_reference=false`` really does is force the framework to
call the setter on the parent object.

Similarly, if you're using the :doc:`collection</reference/forms/types/collection>`
form type where your underlying collection data is an object (like with Doctrine's
``ArrayCollection``), then ``by_reference`` must be set to ``false`` if you
need the adder and remover (e.g. ``addAuthor()`` and ``removeAuthor()``) to be called.
form type where your underlying collection data is an object (like with
Doctrine's ``ArrayCollection``), then ``by_reference`` must be set to ``false``
if you need the adder and remover (e.g. ``addAuthor()`` and ``removeAuthor()``)
to be called.
9 changes: 5 additions & 4 deletions reference/forms/types/options/cascade_validation.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ the data from ``CategoryType`` to also be validated.
.. tip::

Instead of using this option, it is recommended that you use the ``Valid``
constraint in your model to force validation on a child object stored on
a property. This cascades only the validation but not the use of the
``validation_group`` option on child forms. You can read more about this
in the section about :ref:`Embedding a Single Object <forms-embedding-single-object>`.
constraint in your model to force validation on a child object stored
on a property. This cascades only the validation but not the use of
the ``validation_group`` option on child forms. You can read more
about this in the section about
:ref:`Embedding a Single Object <forms-embedding-single-object>`.

.. include:: /reference/forms/types/options/_error_bubbling_hint.rst.inc
6 changes: 3 additions & 3 deletions reference/forms/types/options/compound.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ compound

**type**: ``boolean`` **default**: ``true``

This option specifies if a form is compound. This is independent of whether the
form actually has children. A form can be compound but not have any children
at all (e.g. an empty collection form).
This option specifies if a form is compound. This is independent of whether
the form actually has children. A form can be compound but not have any
children at all (e.g. an empty collection form).
10 changes: 5 additions & 5 deletions reference/forms/types/options/data.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ data

When you create a form, each field initially displays the value of the
corresponding property of the form's domain object (if an object is bound
to the form). If you want to override the initial value for the form or just
an individual field, you can set it in the data option::
to the form). If you want to override the initial value for the form or
just an individual field, you can set it in the data option::

$builder->add('token', 'hidden', array(
'data' => 'abcdef',
));

.. note::

The default values for form fields are taken directly from the
underlying data structure (e.g. an entity or an array).
The ``data`` option overrides this default value.
The default values for form fields are taken directly from the underlying
data structure (e.g. an entity or an array). The ``data`` option overrides
this default value.
4 changes: 2 additions & 2 deletions reference/forms/types/options/data_class.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ data_class

**type**: ``string``

This option is used to set the appropriate data mapper to be used by the form,
so you can use it for any form field type which requires an object.
This option is used to set the appropriate data mapper to be used by the
form, so you can use it for any form field type which requires an object.

.. code-block:: php

Expand Down
17 changes: 9 additions & 8 deletions reference/forms/types/options/date_format.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ format
**type**: ``integer`` or ``string`` **default**: `IntlDateFormatter::MEDIUM`_
(or ``yyyy-MM-dd`` if `widget`_ is ``single_text``)

Option passed to the ``IntlDateFormatter`` class, used to transform user input
into the proper format. This is critical when the `widget`_ option is
set to ``single_text``, and will define how the user will input the data.
Option passed to the ``IntlDateFormatter`` class, used to transform user
input into the proper format. This is critical when the `widget`_ option
is set to ``single_text`` and will define how the user will input the data.
By default, the format is determined based on the current user locale: meaning
that *the expected format will be different for different users*. You
can override it by passing the format as a string.
that *the expected format will be different for different users*. You can
override it by passing the format as a string.

For more information on valid formats, see `Date/Time Format Syntax`_::

Expand All @@ -21,9 +21,10 @@ For more information on valid formats, see `Date/Time Format Syntax`_::

.. note::

If you want your field to be rendered as an HTML5 "date" field, you have to
use a ``single_text`` widget with the ``yyyy-MM-dd`` format (the `RFC 3339`_
format) which is the default value if you use the ``single_text`` widget.
If you want your field to be rendered as an HTML5 "date" field, you
have to use a ``single_text`` widget with the ``yyyy-MM-dd`` format
(the `RFC 3339`_ format) which is the default value if you use the
``single_text`` widget.

.. _`Date/Time Format Syntax`: http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax
.. _`IntlDateFormatter::MEDIUM`: http://www.php.net/manual/en/class.intldateformatter.php#intl.intldateformatter-constants
Expand Down
4 changes: 2 additions & 2 deletions reference/forms/types/options/date_input.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ input

**type**: ``string`` **default**: ``datetime``

The format of the *input* data - i.e. the format that the date is stored on
your underlying object. Valid values are:
The format of the *input* data - i.e. the format that the date is stored
on your underlying object. Valid values are:

* ``string`` (e.g. ``2011-06-05``)
* ``datetime`` (a ``DateTime`` object)
Expand Down
7 changes: 4 additions & 3 deletions reference/forms/types/options/date_widget_description.rst.inc
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
**type**: ``string`` **default**: ``choice``

The basic way in which this field should be rendered. Can be one of the following:
The basic way in which this field should be rendered. Can be one of the
following:

* ``choice``: renders three select inputs. The order of the selects is defined
in the `format`_ option.

* ``text``: renders a three field input of type ``text`` (month, day, year).

* ``single_text``: renders a single input of type ``date``. User's input is
validated based on the `format`_ option.
* ``single_text``: renders a single input of type ``date``. User's input
is validated based on the `format`_ option.
4 changes: 2 additions & 2 deletions reference/forms/types/options/disabled.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ disabled

**type**: ``boolean`` **default**: ``false``

If you don't want a user to modify the value of a field, you can set the disabled
option to true. Any submitted value will be ignored.
If you don't want a user to modify the value of a field, you can set the
disabled option to true. Any submitted value will be ignored.
9 changes: 4 additions & 5 deletions reference/forms/types/options/empty_data.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ empty_data

**type**: ``mixed``

.. This file should only be included with start-after or end-before that's set to
this placeholder value. Its purpose is to let us include only part of this file.
.. This file should only be included with start-after or end-before that's
set to this placeholder value. Its purpose is to let us include only
part of this file.

DEFAULT_PLACEHOLDER

Expand All @@ -13,9 +14,7 @@ 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
selected, you can do it like this:

.. code-block:: php
selected, you can do it like this::

$builder->add('gender', 'choice', array(
'choices' => array(
Expand Down
6 changes: 3 additions & 3 deletions reference/forms/types/options/empty_value.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ empty_value

**type**: ``string`` or ``boolean``

This option determines whether or not a special "empty" option (e.g. "Choose an option")
will appear at the top of a select widget. This option only applies if the
``multiple`` option is set to false.
This option determines whether or not a special "empty" option (e.g. "Choose
an option") will appear at the top of a select widget. This option only
applies if the ``multiple`` option is set to false.

* Add an empty value with "Choose an option" as the text::

Expand Down
4 changes: 2 additions & 2 deletions reference/forms/types/options/error_mapping.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ field so that it displays above it::
Here are the rules for the left and the right side of the mapping:

* The left side contains property paths;
* If the violation is generated on a property or method of a class, its path
is simply ``propertyName``;
* If the violation is generated on a property or method of a class, its
path is simply ``propertyName``;
* If the violation is generated on an entry of an ``array`` or ``ArrayAccess``
object, the property path is ``[indexName]``;
* You can construct nested property paths by concatenating them, separating
Expand Down
10 changes: 5 additions & 5 deletions reference/forms/types/options/grouping.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ grouping

**type**: ``integer`` **default**: ``false``

This value is used internally as the ``NumberFormatter::GROUPING_USED`` value
when using PHP's ``NumberFormatter`` class. Its documentation is non-existent,
but it appears that if you set this to ``true``, numbers will be grouped with
a comma or period (depending on your locale): ``12345.123`` would display
as ``12,345.123``.
This value is used internally as the ``NumberFormatter::GROUPING_USED``
value when using PHP's ``NumberFormatter`` class. Its documentation is
non-existent, but it appears that if you set this to ``true``, numbers will
be grouped with a comma or period (depending on your locale): ``12345.123``
would display as ``12,345.123``.
7 changes: 4 additions & 3 deletions reference/forms/types/options/inherit_data.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ multiple forms. See :doc:`/cookbook/form/inherit_data_option`.

.. caution::

When a field has the ``inherit_data`` option set, it uses the data of the
parent form as is. This means that :doc:`Data Transformers </cookbook/form/data_transformers>`
won't be applied to that field.
When a field has the ``inherit_data`` option set, it uses the data of
the parent form as is. This means that
:doc:`Data Transformers </cookbook/form/data_transformers>` won't be
applied to that field.
6 changes: 3 additions & 3 deletions reference/forms/types/options/invalid_message.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ a :doc:`time</reference/forms/types/time>` field that cannot be converted
into a real time or if the user enters a string (e.g. ``apple``) into a
number field.

Normal (business logic) validation (such as when setting a minimum length for
a field) should be set using validation messages with your validation rules
(:ref:`reference<book-validation-constraint-configuration>`).
Normal (business logic) validation (such as when setting a minimum length
for a field) should be set using validation messages with your validation
rules (:ref:`reference<book-validation-constraint-configuration>`).
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ to that option and including the variables in this option::

$builder->add('some_field', 'some_type', array(
// ...
'invalid_message' => 'You entered an invalid value - it should include %num% letters',
'invalid_message' => 'You entered an invalid value, it should include %num% letters',
'invalid_message_parameters' => array('%num%' => 6),
));
11 changes: 7 additions & 4 deletions reference/forms/types/options/label_attr.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ label_attr

**type**: ``array`` **default**: ``array()``

Sets the HTML attributes for the ``<label>`` element, which will be used when
rendering the label for the field. It's an associative array with HTML attribute
as a key. This attributes can also be directly set inside the template:
Sets the HTML attributes for the ``<label>`` element, which will be used
when rendering the label for the field. It's an associative array with HTML
attribute as a key. This attributes can also be directly set inside the
template:

.. configuration-block::

.. code-block:: jinja

{{ form_label(form.name, 'Your name', {'label_attr': {'class': 'CUSTOM_LABEL_CLASS'}}) }}
{{ form_label(form.name, 'Your name', {
'label_attr': {'class': 'CUSTOM_LABEL_CLASS'}
}) }}

.. code-block:: php

Expand Down
4 changes: 2 additions & 2 deletions reference/forms/types/options/mapped.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ mapped

**type**: ``boolean`` **default**: ``true``

If you wish the field to be ignored when reading or writing to the object, you
can set the ``mapped`` option to ``false``.
If you wish the field to be ignored when reading or writing to the object,
you can set the ``mapped`` option to ``false``.
12 changes: 6 additions & 6 deletions reference/forms/types/options/method.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ method
**type**: ``string`` **default**: ``POST``

This option specifies the HTTP method used to submit the form's data. Its
value is rendered as the ``method`` attribute of the ``form`` element and is
used to decide whether to process the form submission in the
value is rendered as the ``method`` attribute of the ``form`` element and
is used to decide whether to process the form submission in the
``handleRequest()`` method after submission. Possible values are:
* POST
Expand All @@ -26,8 +26,8 @@ used to decide whether to process the form submission in the

.. note::

The PATCH method allows submitting partial data. In other words, if the
submitted form data is missing certain fields, those will be ignored
The PATCH method allows submitting partial data. In other words, if
the submitted form data is missing certain fields, those will be ignored
and the default values (if any) will be used. With all other HTTP methods,
if the submitted form data is missing some fields, those fields are set
to ``null``.
if the submitted form data is missing some fields, those fields are
set to ``null``.
4 changes: 2 additions & 2 deletions reference/forms/types/options/pattern.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pattern

**type**: ``string`` **default**: ``null``

This adds an HTML5 ``pattern`` attribute to restrict the field input by a
given regular expression.
This adds an HTML5 ``pattern`` attribute to restrict the field input by
a given regular expression.

.. caution::

Expand Down
4 changes: 2 additions & 2 deletions reference/forms/types/options/post_max_size_message.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ post_max_size_message

**type**: ``string`` **default**: ``The uploaded file was too large. Please try to upload a smaller file.``

This is the validation error message that's used if submitted POST form data
exceeds ``php.ini``'s ``post_max_size`` directive. The ``{{ max }}``
This is the validation error message that's used if submitted POST form
data exceeds ``php.ini``'s ``post_max_size`` directive. The ``{{ max }}``
placeholder can be used to display the allowed size.

.. note::
Expand Down
9 changes: 6 additions & 3 deletions reference/forms/types/options/preferred_choices.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ preferred_choices
**type**: ``array`` **default**: ``array()``

If this option is specified, then a sub-set of all of the options will be
moved to the top of the select menu. The following would move the "Baz" option
to the top, with a visual separator between it and the rest of the options::
moved to the top of the select menu. The following would move the "Baz"
option to the top, with a visual separator between it and the rest of the
options::

$builder->add('foo_choices', 'choice', array(
'choices' => array('foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz'),
Expand All @@ -25,4 +26,6 @@ This can be customized when rendering the field:

.. code-block:: php

<?php echo $view['form']->widget($form['foo_choices'], array('separator' => '=====')) ?>
<?php echo $view['form']->widget($form['foo_choices'], array(
'separator' => '====='
)) ?>
9 changes: 5 additions & 4 deletions reference/forms/types/options/property_path.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ property_path

**type**: ``any`` **default**: ``the field's name``
Fields display a property value of the form's domain object by default. When
the form is submitted, the submitted value is written back into the object.
Fields display a property value of the form's domain object by default.
When the form is submitted, the submitted value is written back into the
object.

If you want to override the property that a field reads from and writes to,
you can set the ``property_path`` option. Its default value is the field's
If you want to override the property that a field reads from and writes
to, you can set the ``property_path`` option. Its default value is the field's
name.
If you wish the field to be ignored when reading or writing to the object
Expand Down
6 changes: 3 additions & 3 deletions reference/forms/types/options/required.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ required
If true, an `HTML5 required attribute`_ will be rendered. The corresponding
``label`` will also render with a ``required`` class.

This is superficial and independent from validation. At best, if you let Symfony
guess your field type, then the value of this option will be guessed from
your validation information.
This is superficial and independent from validation. At best, if you let
Symfony guess your field type, then the value of this option will be guessed
from your validation information.

.. note::

Expand Down
4 changes: 2 additions & 2 deletions reference/forms/types/options/trim.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ trim
**type**: ``boolean`` **default**: ``true``

If true, the whitespace of the submitted string value will be stripped
via the :phpfunction:`trim` function when the data is bound. This guarantees that
if a value is submitted with extra whitespace, it will be removed before
via the :phpfunction:`trim` function when the data is bound. This guarantees
that if a value is submitted with extra whitespace, it will be removed before
the value is merged back onto the underlying object.
Loading

0 comments on commit 03fdc5b

Please sign in to comment.