Skip to content

Commit

Permalink
Completely updating the form type reference section for the text -> T…
Browse files Browse the repository at this point in the history
…extType changes
  • Loading branch information
weaverryan committed Nov 30, 2015
1 parent 832a12a commit feb68dd
Show file tree
Hide file tree
Showing 34 changed files with 299 additions and 324 deletions.
9 changes: 8 additions & 1 deletion reference/forms/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
Form Types Reference
====================

.. versionadded:: 2.8
To denote the form type, you have to use the fully qualified class name - like
``TextType::class`` in PHP 5.5+ or ``Symfony\Component\Form\Extension\Core\Type\TextType``.
Before Symfony 2.8, you could use an alias for each type like ``text`` or
``date``. The old alias syntax will still work until Symfony 3.0. For more details,
see the `2.8 UPGRADE Log`_.

.. toctree::
:maxdepth: 1
:hidden:
Expand Down Expand Up @@ -49,7 +56,7 @@ Form Types Reference
types/form

A form is composed of *fields*, each of which are built with the help of
a field *type* (e.g. a ``text`` type, ``choice`` type, etc). Symfony comes
a field *type* (e.g. ``TextType``, ``ChoiceType``, etc). Symfony comes
standard with a large list of field types that can be used in your application.

Supported Field Types
Expand Down
22 changes: 10 additions & 12 deletions reference/forms/types/birthday.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
.. index::
single: Forms; Fields; birthday
single: Forms; Fields; BirthdayType

birthday Field Type
===================
BirthdayType Field
==================

A :doc:`date </reference/forms/types/date>` field that specializes in handling
A :doc:`DateType </reference/forms/types/date>` field that specializes in handling
birthdate data.

Can be rendered as a single text box, three text boxes (month, day and year),
or three select boxes.

This type is essentially the same as the :doc:`date </reference/forms/types/date>`
This type is essentially the same as the :doc:`DateType </reference/forms/types/date>`
type, but with a more appropriate default for the `years`_ option. The `years`_
option defaults to 120 years ago to the current year.

Expand All @@ -22,7 +22,7 @@ option defaults to 120 years ago to the current year.
+----------------------+-------------------------------------------------------------------------------+
| Overridden options | - `years`_ |
+----------------------+-------------------------------------------------------------------------------+
| Inherited options | from the :doc:`date </reference/forms/types/date>` type: |
| Inherited options | from the :doc:`DateType </reference/forms/types/date>`: |
| | |
| | - `days`_ |
| | - `placeholder`_ |
Expand All @@ -33,7 +33,7 @@ option defaults to 120 years ago to the current year.
| | - `view_timezone`_ |
| | - `widget`_ |
| | |
| | from the :doc:`form </reference/forms/types/form>` type: |
| | from the :doc:`FormType </reference/forms/types/form>`: |
| | |
| | - `data`_ |
| | - `disabled`_ |
Expand All @@ -43,7 +43,7 @@ option defaults to 120 years ago to the current year.
| | - `mapped`_ |
| | - `read_only`_ (deprecated as of 2.8) |
+----------------------+-------------------------------------------------------------------------------+
| Parent type | :doc:`date </reference/forms/types/date>` |
| Parent type | :doc:`DateType </reference/forms/types/date>` |
+----------------------+-------------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\BirthdayType` |
+----------------------+-------------------------------------------------------------------------------+
Expand All @@ -62,8 +62,7 @@ relevant when the ``widget`` option is set to ``choice``.
Inherited Options
-----------------

These options inherit from the :doc:`date </reference/forms/types/date>`
type:
These options inherit from the :doc:`DateType </reference/forms/types/date>`:

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

Expand All @@ -81,8 +80,7 @@ type:

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

These options inherit from the :doc:`form </reference/forms/types/form>`
type:
These options inherit from the :doc:`FormType </reference/forms/types/form>`:

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

Expand Down
10 changes: 5 additions & 5 deletions reference/forms/types/button.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.. index::
single: Forms; Fields; button
single: Forms; Fields; ButtonType

button Field Type
=================
ButtonType Field
================

.. versionadded:: 2.3
The ``button`` type was introduced in Symfony 2.3
The ``ButtonType`` was introduced in Symfony 2.3

A simple, non-responsive button.

Expand All @@ -28,7 +28,7 @@ Inherited Options
The following options are defined in the
:class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\BaseType` class.
The ``BaseType`` class is the parent class for both the ``button`` type
and the :doc:`form type </reference/forms/types/form>`, but it is not part
and the :doc:`FormType </reference/forms/types/form>`, but it is not part
of the form type tree (i.e. it can not be used as a form type on its own).

.. include:: /reference/forms/types/options/button_attr.rst.inc
Expand Down
11 changes: 5 additions & 6 deletions reference/forms/types/checkbox.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.. index::
single: Forms; Fields; checkbox
single: Forms; Fields; CheckboxType

checkbox Field Type
===================
CheckboxType Field
==================

Creates a single input checkbox. This should always be used for a field
that has a boolean value: if the box is checked, the field will be set to
Expand All @@ -26,7 +26,7 @@ true, if the box is unchecked, the value will be set to false.
| | - `read_only`_ (deprecated as of 2.8) |
| | - `required`_ |
+-------------+------------------------------------------------------------------------+
| Parent type | :doc:`form </reference/forms/types/form>` |
| Parent type | :doc:`FormType </reference/forms/types/form>` |
+-------------+------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CheckboxType` |
+-------------+------------------------------------------------------------------------+
Expand Down Expand Up @@ -59,8 +59,7 @@ Overridden Options
Inherited Options
-----------------

These options inherit from the :doc:`form </reference/forms/types/form>`
type:
These options inherit from the :doc:`FormType </reference/forms/types/form>`:

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

Expand Down
12 changes: 6 additions & 6 deletions reference/forms/types/choice.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.. index::
single: Forms; Fields; choice
single: Forms; Fields; ChoiceType

choice Field Type (select drop-downs, radio buttons & checkboxes)
=================================================================
ChoiceType Field (select drop-downs, radio buttons & checkboxes)
================================================================

A multi-purpose field used to allow the user to "choose" one or more options.
It can be rendered as a ``select`` tag, radio buttons, or checkboxes.
Expand Down Expand Up @@ -41,7 +41,7 @@ To use this field, you must specify *either* ``choices`` or ``choice_loader`` op
| | - `read_only`_ (deprecated as of 2.8) |
| | - `required`_ |
+-------------+------------------------------------------------------------------------------+
| Parent type | :doc:`form </reference/forms/types/form>` |
| Parent type | :doc:`FormType </reference/forms/types/form>` |
+-------------+------------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\ChoiceType` |
+-------------+------------------------------------------------------------------------------+
Expand Down Expand Up @@ -91,6 +91,7 @@ this example, the underlying data is some ``Category`` object that has a ``getNa
method::

use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use AppBundle\Entity\Category;
// ...

$builder->add('category', ChoiceType::class, [
Expand Down Expand Up @@ -333,8 +334,7 @@ the parent field (the form in most cases).
Inherited Options
-----------------

These options inherit from the :doc:`form </reference/forms/types/form>`
type:
These options inherit from the :doc:`FormType </reference/forms/types/form>`:

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

Expand Down
27 changes: 13 additions & 14 deletions reference/forms/types/collection.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.. index::
single: Forms; Fields; collection
single: Forms; Fields; CollectionType

collection Field Type
=====================
CollectionType Field
====================

This field type is used to render a "collection" of some field or form.
In the easiest sense, it could be an array of ``text`` fields that populate
an array ``emails`` field. In more complex examples, you can embed entire
In the easiest sense, it could be an array of ``TextType`` fields that populate
an array ``emails`` values. In more complex examples, you can embed entire
forms, which is useful when creating forms that expose one-to-many
relationships (e.g. a product from where you can manage many related product
photos).
Expand All @@ -32,7 +32,7 @@ photos).
| | - `mapped`_ |
| | - `required`_ |
+-------------+-----------------------------------------------------------------------------+
| Parent type | :doc:`form </reference/forms/types/form>` |
| Parent type | :doc:`FormType </reference/forms/types/form>` |
+-------------+-----------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CollectionType` |
+-------------+-----------------------------------------------------------------------------+
Expand Down Expand Up @@ -287,8 +287,8 @@ entry_options
**type**: ``array`` **default**: ``array()``

This is the array that's passed to the form type specified in the `entry_type`_
option. For example, if you used the :doc:`choice </reference/forms/types/choice>`
type as your `entry_type`_ option (e.g. for a collection of drop-down menus),
option. For example, if you used the :doc:`ChoiceType </reference/forms/types/choice>`
as your `entry_type`_ option (e.g. for a collection of drop-down menus),
then you'd need to at least pass the ``choices`` option to the underlying
type::

Expand Down Expand Up @@ -317,9 +317,9 @@ entry_type

**type**: ``string`` or :class:`Symfony\\Component\\Form\\FormTypeInterface` **required**

This is the field type for each item in this collection (e.g. ``text``,
``choice``, etc). For example, if you have an array of email addresses,
you'd use the :doc:`email </reference/forms/types/email>` type. If you want
This is the field type for each item in this collection (e.g. ``TextType``,
``ChoiceType``, etc). For example, if you have an array of email addresses,
you'd use the :doc:`EmailType </reference/forms/types/email>`. If you want
to embed a collection of some other form, create a new instance of your
form type and pass it as this option.

Expand Down Expand Up @@ -374,9 +374,8 @@ not replaced with the same value.
Inherited Options
-----------------

These options inherit from the :doc:`form </reference/forms/types/form>`
type. Not all options are listed here - only the most applicable to this
type:
These options inherit from the :doc:`FormType </reference/forms/types/form>`.
Not all options are listed here - only the most applicable to this type:

.. _reference-form-types-by-reference:

Expand Down
25 changes: 11 additions & 14 deletions reference/forms/types/country.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.. index::
single: Forms; Fields; country

country Field Type
==================
CountryType Field
=================

The ``country`` type is a subset of the ``ChoiceType`` that displays countries
The ``CountryType`` is a subset of the ``ChoiceType`` that displays countries
of the world. As an added bonus, the country names are displayed in the
language of the user.

Expand All @@ -14,18 +14,17 @@ The "value" for each country is the two-letter country code.

The locale of your user is guessed using :phpmethod:`Locale::getDefault`

Unlike the ``choice`` type, you don't need to specify a ``choices`` or
``choice_list`` option as the field type automatically uses all of the countries
of the world. You *can* specify either of these options manually, but then
you should just use the ``choice`` type directly.
Unlike the ``ChoiceType``, you don't need to specify a ``choices`` option as the
field type automatically uses all of the countries of the world. You *can* specify
the option manually, but then you should just use the ``ChoiceType`` directly.

+-------------+-----------------------------------------------------------------------+
| Rendered as | can be various tags (see :ref:`forms-reference-choice-tags`) |
+-------------+-----------------------------------------------------------------------+
| Overridden | - `choices`_ |
| options | |
+-------------+-----------------------------------------------------------------------+
| Inherited | from the :doc:`choice </reference/forms/types/choice>` type |
| Inherited | from the :doc:`ChoiceType </reference/forms/types/choice>` |
| options | |
| | - `placeholder`_ |
| | - `error_bubbling`_ |
Expand All @@ -34,7 +33,7 @@ you should just use the ``choice`` type directly.
| | - `multiple`_ |
| | - `preferred_choices`_ |
| | |
| | from the :doc:`form </reference/forms/types/form>` type |
| | from the :doc:`FormType </reference/forms/types/form>` |
| | |
| | - `data`_ |
| | - `disabled`_ |
Expand All @@ -45,7 +44,7 @@ you should just use the ``choice`` type directly.
| | - `read_only`_ (deprecated as of 2.8) |
| | - `required`_ |
+-------------+-----------------------------------------------------------------------+
| Parent type | :doc:`choice </reference/forms/types/choice>` |
| Parent type | :doc:`ChoiceType </reference/forms/types/choice>` |
+-------------+-----------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CountryType` |
+-------------+-----------------------------------------------------------------------+
Expand All @@ -64,8 +63,7 @@ The locale is used to translate the countries names.
Inherited Options
-----------------

These options inherit from the :doc:`choice </reference/forms/types/choice>`
type:
These options inherit from the :doc:`ChoiceType </reference/forms/types/choice>`:

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

Expand All @@ -79,8 +77,7 @@ type:

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

These options inherit from the :doc:`form </reference/forms/types/form>`
type:
These options inherit from the :doc:`FormType </reference/forms/types/form>`:

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

Expand Down
Loading

0 comments on commit feb68dd

Please sign in to comment.