From feb68dd29181fef80f4c65beafa5c75ad2245812 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sun, 29 Nov 2015 22:47:27 -0500 Subject: [PATCH] Completely updating the form type reference section for the text -> TextType changes --- reference/forms/types.rst | 9 +++- reference/forms/types/birthday.rst | 22 +++++----- reference/forms/types/button.rst | 10 ++--- reference/forms/types/checkbox.rst | 11 +++-- reference/forms/types/choice.rst | 12 +++--- reference/forms/types/collection.rst | 27 ++++++------ reference/forms/types/country.rst | 25 +++++------ reference/forms/types/currency.rst | 28 ++++++------ reference/forms/types/date.rst | 17 +++++--- reference/forms/types/datetime.rst | 20 ++++----- reference/forms/types/email.rst | 13 +++--- reference/forms/types/entity.rst | 43 ++++++++++--------- reference/forms/types/file.rst | 13 +++--- reference/forms/types/form.rst | 12 +++--- reference/forms/types/hidden.rst | 9 ++-- reference/forms/types/integer.rst | 11 +++-- reference/forms/types/language.rst | 27 ++++++------ reference/forms/types/locale.rst | 27 ++++++------ reference/forms/types/map.rst.inc | 64 ++++++++++++++-------------- reference/forms/types/money.rst | 13 +++--- reference/forms/types/number.rst | 11 +++-- reference/forms/types/password.rst | 15 +++---- reference/forms/types/percent.rst | 13 +++--- reference/forms/types/radio.rst | 24 +++++------ reference/forms/types/range.rst | 13 +++--- reference/forms/types/repeated.rst | 22 +++++----- reference/forms/types/reset.rst | 10 ++--- reference/forms/types/search.rst | 11 +++-- reference/forms/types/submit.rst | 10 ++--- reference/forms/types/text.rst | 13 +++--- reference/forms/types/textarea.rst | 11 +++-- reference/forms/types/time.rst | 15 +++---- reference/forms/types/timezone.rst | 29 ++++++------- reference/forms/types/url.rst | 13 +++--- 34 files changed, 299 insertions(+), 324 deletions(-) diff --git a/reference/forms/types.rst b/reference/forms/types.rst index 5df657d1910..6dbfb54010c 100644 --- a/reference/forms/types.rst +++ b/reference/forms/types.rst @@ -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: @@ -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 diff --git a/reference/forms/types/birthday.rst b/reference/forms/types/birthday.rst index 740c885efba..5a31c5cde4c 100644 --- a/reference/forms/types/birthday.rst +++ b/reference/forms/types/birthday.rst @@ -1,16 +1,16 @@ .. index:: - single: Forms; Fields; birthday + single: Forms; Fields; BirthdayType -birthday Field Type -=================== +BirthdayType Field +================== -A :doc:`date ` field that specializes in handling +A :doc:`DateType ` 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 ` +This type is essentially the same as the :doc:`DateType ` type, but with a more appropriate default for the `years`_ option. The `years`_ option defaults to 120 years ago to the current year. @@ -22,7 +22,7 @@ option defaults to 120 years ago to the current year. +----------------------+-------------------------------------------------------------------------------+ | Overridden options | - `years`_ | +----------------------+-------------------------------------------------------------------------------+ -| Inherited options | from the :doc:`date ` type: | +| Inherited options | from the :doc:`DateType `: | | | | | | - `days`_ | | | - `placeholder`_ | @@ -33,7 +33,7 @@ option defaults to 120 years ago to the current year. | | - `view_timezone`_ | | | - `widget`_ | | | | -| | from the :doc:`form ` type: | +| | from the :doc:`FormType `: | | | | | | - `data`_ | | | - `disabled`_ | @@ -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 ` | +| Parent type | :doc:`DateType ` | +----------------------+-------------------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\BirthdayType` | +----------------------+-------------------------------------------------------------------------------+ @@ -62,8 +62,7 @@ relevant when the ``widget`` option is set to ``choice``. Inherited Options ----------------- -These options inherit from the :doc:`date ` -type: +These options inherit from the :doc:`DateType `: .. include:: /reference/forms/types/options/days.rst.inc @@ -81,8 +80,7 @@ type: .. include:: /reference/forms/types/options/date_widget.rst.inc -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/button.rst b/reference/forms/types/button.rst index 2ed5ac1750d..17910f6a67c 100644 --- a/reference/forms/types/button.rst +++ b/reference/forms/types/button.rst @@ -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. @@ -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 `, but it is not part +and the :doc:`FormType `, 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 diff --git a/reference/forms/types/checkbox.rst b/reference/forms/types/checkbox.rst index 5f774a3498e..1f1a0efa25d 100644 --- a/reference/forms/types/checkbox.rst +++ b/reference/forms/types/checkbox.rst @@ -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 @@ -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 ` | +| Parent type | :doc:`FormType ` | +-------------+------------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CheckboxType` | +-------------+------------------------------------------------------------------------+ @@ -59,8 +59,7 @@ Overridden Options Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index 1a9c101fbcf..be0bf17265a 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -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. @@ -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 ` | +| Parent type | :doc:`FormType ` | +-------------+------------------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\ChoiceType` | +-------------+------------------------------------------------------------------------------+ @@ -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, [ @@ -333,8 +334,7 @@ the parent field (the form in most cases). Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/by_reference.rst.inc diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index 3dfdddfe435..269f00977d2 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -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). @@ -32,7 +32,7 @@ photos). | | - `mapped`_ | | | - `required`_ | +-------------+-----------------------------------------------------------------------------+ -| Parent type | :doc:`form ` | +| Parent type | :doc:`FormType ` | +-------------+-----------------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CollectionType` | +-------------+-----------------------------------------------------------------------------+ @@ -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 ` -type as your `entry_type`_ option (e.g. for a collection of drop-down menus), +option. For example, if you used the :doc:`ChoiceType ` +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:: @@ -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 ` 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 `. 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. @@ -374,9 +374,8 @@ not replaced with the same value. Inherited Options ----------------- -These options inherit from the :doc:`form ` -type. Not all options are listed here - only the most applicable to this -type: +These options inherit from the :doc:`FormType `. +Not all options are listed here - only the most applicable to this type: .. _reference-form-types-by-reference: diff --git a/reference/forms/types/country.rst b/reference/forms/types/country.rst index e7b7226c067..abe34f03546 100644 --- a/reference/forms/types/country.rst +++ b/reference/forms/types/country.rst @@ -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. @@ -14,10 +14,9 @@ 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`) | @@ -25,7 +24,7 @@ you should just use the ``choice`` type directly. | Overridden | - `choices`_ | | options | | +-------------+-----------------------------------------------------------------------+ -| Inherited | from the :doc:`choice ` type | +| Inherited | from the :doc:`ChoiceType ` | | options | | | | - `placeholder`_ | | | - `error_bubbling`_ | @@ -34,7 +33,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `preferred_choices`_ | | | | -| | from the :doc:`form ` type | +| | from the :doc:`FormType ` | | | | | | - `data`_ | | | - `disabled`_ | @@ -45,7 +44,7 @@ you should just use the ``choice`` type directly. | | - `read_only`_ (deprecated as of 2.8) | | | - `required`_ | +-------------+-----------------------------------------------------------------------+ -| Parent type | :doc:`choice ` | +| Parent type | :doc:`ChoiceType ` | +-------------+-----------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CountryType` | +-------------+-----------------------------------------------------------------------+ @@ -64,8 +63,7 @@ The locale is used to translate the countries names. Inherited Options ----------------- -These options inherit from the :doc:`choice ` -type: +These options inherit from the :doc:`ChoiceType `: .. include:: /reference/forms/types/options/placeholder.rst.inc @@ -79,8 +77,7 @@ type: .. include:: /reference/forms/types/options/preferred_choices.rst.inc -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/currency.rst b/reference/forms/types/currency.rst index 5fa7d19b720..3281314e4cf 100644 --- a/reference/forms/types/currency.rst +++ b/reference/forms/types/currency.rst @@ -1,17 +1,15 @@ .. index:: single: Forms; Fields; currency -currency Field Type -=================== +CurrencyType Field +================== -The ``currency`` type is a subset of the -:doc:`choice type ` that allows the user -to select from a large list of `3-letter ISO 4217`_ currencies. +The ``CurrencyType`` is a subset of the :doc:`ChoiceType ` +that allows the user to select from a large list of `3-letter ISO 4217`_ currencies. -Unlike the ``choice`` type, you don't need to specify a ``choices`` or -``choice_list`` option as the field type automatically uses a large list -of currencies. 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 a large list of currencies. 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`) | @@ -19,7 +17,7 @@ you should just use the ``choice`` type directly. | Overridden | - `choices`_ | | options | | +-------------+------------------------------------------------------------------------+ -| Inherited | from the :doc:`choice ` type | +| Inherited | from the :doc:`ChoiceType ` | | options | | | | - `placeholder`_ | | | - `error_bubbling`_ | @@ -27,7 +25,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `preferred_choices`_ | | | | -| | from the :doc:`form ` type | +| | from the :doc:`FormType ` type | | | | | | - `data`_ | | | - `disabled`_ | @@ -38,7 +36,7 @@ you should just use the ``choice`` type directly. | | - `read_only`_ (deprecated as of 2.8) | | | - `required`_ | +-------------+------------------------------------------------------------------------+ -| Parent type | :doc:`choice ` | +| Parent type | :doc:`ChoiceType ` | +-------------+------------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CurrencyType` | +-------------+------------------------------------------------------------------------+ @@ -56,8 +54,7 @@ The choices option defaults to all currencies. Inherited Options ----------------- -These options inherit from the :doc:`choice` -type: +These options inherit from the :doc:`ChoiceType `: .. include:: /reference/forms/types/options/placeholder.rst.inc @@ -69,8 +66,7 @@ type: .. include:: /reference/forms/types/options/preferred_choices.rst.inc -These options inherit from the :doc:`form` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/date.rst b/reference/forms/types/date.rst index e374b93f946..2d93e10a00f 100644 --- a/reference/forms/types/date.rst +++ b/reference/forms/types/date.rst @@ -1,8 +1,8 @@ .. index:: - single: Forms; Fields; date + single: Forms; Fields; DateType -date Field Type -=============== +DateType Field +============== A field that allows the user to modify date information via a variety of different HTML elements. @@ -44,7 +44,7 @@ day and year) or three select boxes (see the `widget`_ option). | | - `mapped`_ | | | - `read_only`_ (deprecated as of 2.8) | +----------------------+-----------------------------------------------------------------------------+ -| Parent type | :doc:`form ` | +| Parent type | :doc:`FormType ` | +----------------------+-----------------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\DateType` | +----------------------+-----------------------------------------------------------------------------+ @@ -59,6 +59,9 @@ Suppose that you have a ``publishedAt`` field whose underlying date is a ``DateTime`` object. The following configures the ``DateType`` type for that field as three different choice fields:: + use Symfony\Component\Form\Extension\Core\Type\DateType; + // ... + $builder->add('publishedAt', DateType::class, array( 'input' => 'datetime', 'widget' => 'choice', @@ -68,6 +71,9 @@ The ``input`` option *must* be changed to match the type of the underlying date data. For example, if the ``publishedAt`` field's data were a unix timestamp, you'd need to set ``input`` to ``timestamp``:: + use Symfony\Component\Form\Extension\Core\Type\DateType; + // ... + $builder->add('publishedAt', DateType::class, array( 'input' => 'timestamp', 'widget' => 'choice', @@ -146,8 +152,7 @@ error_bubbling Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/datetime.rst b/reference/forms/types/datetime.rst index 58471e175b8..087e99478e9 100644 --- a/reference/forms/types/datetime.rst +++ b/reference/forms/types/datetime.rst @@ -1,8 +1,8 @@ .. index:: - single: Forms; Fields; datetime + single: Forms; Fields; DateTimeType -datetime Field Type -=================== +DateTimeType Field +================== This field type allows the user to modify data that represents a specific date and time (e.g. ``1984-06-05 12:15:30``). @@ -47,7 +47,7 @@ the data can be a ``DateTime`` object, a string, a timestamp or an array. | | - `mapped`_ | | | - `read_only`_ (deprecated as of 2.8) | +----------------------+-----------------------------------------------------------------------------+ -| Parent type | :doc:`form ` | +| Parent type | :doc:`FormType ` | +----------------------+-----------------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\DateTimeType` | +----------------------+-----------------------------------------------------------------------------+ @@ -61,7 +61,7 @@ date_format **type**: ``integer`` or ``string`` **default**: ``IntlDateFormatter::MEDIUM`` Defines the ``format`` option that will be passed down to the date field. -See the :ref:`date type's format option ` +See the :ref:`DateType's format option ` for more details. date_widget @@ -119,8 +119,7 @@ time_widget **type**: ``string`` **default**: ``choice`` -Defines the ``widget`` option for the :doc:`time ` -type +Defines the ``widget`` option for the :doc:`TimeType `. .. include:: /reference/forms/types/options/view_timezone.rst.inc @@ -129,8 +128,8 @@ widget **type**: ``string`` **default**: ``null`` -Defines the ``widget`` option for both the :doc:`date ` -type and :doc:`time ` type. This can be overridden +Defines the ``widget`` option for both the :doc:`DateType ` +and :doc:`TimeType `. This can be overridden with the `date_widget`_ and `time_widget`_ options. .. include:: /reference/forms/types/options/with_minutes.rst.inc @@ -161,8 +160,7 @@ error_bubbling Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/email.rst b/reference/forms/types/email.rst index 58b68da5cc8..9e70150ec5a 100644 --- a/reference/forms/types/email.rst +++ b/reference/forms/types/email.rst @@ -1,10 +1,10 @@ .. index:: - single: Forms; Fields; email + single: Forms; Fields; EmailType -email Field Type -================ +EmailType Field +=============== -The ``email`` field is a text field that is rendered using the HTML5 +The ``EmailType`` field is a text field that is rendered using the HTML5 ```` tag. +-------------+---------------------------------------------------------------------+ @@ -23,7 +23,7 @@ The ``email`` field is a text field that is rendered using the HTML5 | | - `required`_ | | | - `trim`_ | +-------------+---------------------------------------------------------------------+ -| Parent type | :doc:`text ` | +| Parent type | :doc:`TextType ` | +-------------+---------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType` | +-------------+---------------------------------------------------------------------+ @@ -31,8 +31,7 @@ The ``email`` field is a text field that is rendered using the HTML5 Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/entity.rst b/reference/forms/types/entity.rst index a0487477029..4eacb7078f8 100644 --- a/reference/forms/types/entity.rst +++ b/reference/forms/types/entity.rst @@ -1,10 +1,10 @@ .. index:: - single: Forms; Fields; choice + single: Forms; Fields; EntityType -entity Field Type -================= +EntityType Field +================ -A special ``choice`` field that's designed to load options from a Doctrine +A special ``ChoiceType`` field that's designed to load options from a Doctrine entity. For example, if you have a ``Category`` entity, you could use this field to display a ``select`` field of all, or some, of the ``Category`` objects from the database. @@ -20,7 +20,7 @@ objects from the database. | Overridden | - `choices`_ | | options | | +-------------+------------------------------------------------------------------+ -| Inherited | from the :doc:`choice ` type: | +| Inherited | from the :doc:`ChoiceType `: | | options | | | | - `placeholder`_ | | | - `expanded`_ | @@ -28,7 +28,7 @@ objects from the database. | | - `preferred_choices`_ | | | - `group_by`_ | | | | -| | from the :doc:`form ` type: | +| | from the :doc:`FormType `: | | | | | | - `data`_ | | | - `disabled`_ | @@ -41,7 +41,7 @@ objects from the database. | | - `read_only`_ (deprecated as of 2.8) | | | - `required`_ | +-------------+------------------------------------------------------------------+ -| Parent type | :doc:`choice ` | +| Parent type | :doc:`ChoiceType ` | +-------------+------------------------------------------------------------------+ | Class | :class:`Symfony\\Bridge\\Doctrine\\Form\\Type\\EntityType` | +-------------+------------------------------------------------------------------+ @@ -56,15 +56,18 @@ be listed inside the choice field:: // ... $builder->add('users', EntityType::class, array( - 'class' => 'AcmeHelloBundle:User', + 'class' => 'AppBundle:User', 'choice_label' => 'username', )); In this case, all ``User`` objects will be loaded from the database and rendered as either a ``select`` tag, a set or radio buttons or a series of checkboxes (this depends on the ``multiple`` and ``expanded`` values). -If the entity object does not have a ``__toString()`` method the ``choice_label`` -option is needed. +Because of the `choice_label`_ option, the ``username`` property (usually by calling +``getUsername()``) will be used as the text to display in the field. + +If you omit the ``choice_label`` option, then your entity *must* have a ``__toString()`` +method. Using a Custom Query for the Entities ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -78,7 +81,7 @@ the ``query_builder`` option. The easiest way to use the option is as follows:: // ... $builder->add('users', EntityType::class, array( - 'class' => 'AcmeHelloBundle:User', + 'class' => 'AppBundle:User', 'query_builder' => function (EntityRepository $er) { return $er->createQueryBuilder('u') ->orderBy('u.username', 'ASC'); @@ -100,7 +103,7 @@ then you can supply the ``choices`` option directly:: // ... $builder->add('users', EntityType::class, array( - 'class' => 'AcmeHelloBundle:User', + 'class' => 'AppBundle:User', 'choices' => $group->getUsers(), )); @@ -114,8 +117,8 @@ class **type**: ``string`` **required** -The class of your entity (e.g. ``AcmeStoreBundle:Category``). This can be -a fully-qualified class name (e.g. ``Acme\StoreBundle\Entity\Category``) +The class of your entity (e.g. ``AppBundle:Category``). This can be +a fully-qualified class name (e.g. ``AppBundle\Entity\Category``) or the short alias name (as shown prior). choice_label @@ -167,7 +170,7 @@ more detais, see the main :ref:`choice_label ` docu // ... $builder->add('gender', EntityType::class, array( - 'class' => 'MyBundle:Gender', + 'class' => 'AppBundle:Category', 'choice_label' => 'translations[en].name', )); @@ -206,8 +209,7 @@ See :ref:`reference-forms-entity-choices`. Inherited Options ----------------- -These options inherit from the :doc:`choice ` -type: +These options inherit from the :doc:`ChoiceType `: .. include:: /reference/forms/types/options/placeholder.rst.inc @@ -229,11 +231,10 @@ type: .. note:: - This option expects an array of entity objects, unlike the ``choice`` - field that requires an array of keys. + This option expects an array of entity objects (that's actually the same as with + the ``ChoiceType`` field, whichs requires an array of the preferred "values"). -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/file.rst b/reference/forms/types/file.rst index b31b72a3f18..2f964867111 100644 --- a/reference/forms/types/file.rst +++ b/reference/forms/types/file.rst @@ -1,10 +1,10 @@ .. index:: - single: Forms; Fields; file + single: Forms; Fields; FileType -file Field Type -=============== +FileType Field +============== -The ``file`` type represents a file input in your form. +The ``FileType`` represents a file input in your form. +-------------+---------------------------------------------------------------------+ | Rendered as | ``input`` ``file`` field | @@ -24,7 +24,7 @@ The ``file`` type represents a file input in your form. | | - `read_only`_ (deprecated as of 2.8) | | | - `required`_ | +-------------+---------------------------------------------------------------------+ -| Parent type | :doc:`form ` | +| Parent type | :doc:`FormType ` | +-------------+---------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\FileType` | +-------------+---------------------------------------------------------------------+ @@ -115,8 +115,7 @@ value is empty. Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/disabled.rst.inc diff --git a/reference/forms/types/form.rst b/reference/forms/types/form.rst index 860ff593d45..ccd229795d4 100644 --- a/reference/forms/types/form.rst +++ b/reference/forms/types/form.rst @@ -1,11 +1,11 @@ .. index:: - single: Forms; Fields; form + single: Forms; Fields; FormType -form Field Type -=============== +FormType Field +============== -The ``form`` type predefines a couple of options that are then available -on all types for which ``form`` is the parent type. +The ``FormType`` predefines a couple of options that are then available +on all types for which ``FormType`` is the parent. +-----------+--------------------------------------------------------------------+ | Options | - `action`_ | @@ -146,7 +146,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 ``form`` type and -the :doc:`button type `, but it is not part +the :doc:`ButtonType `, 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/attr.rst.inc diff --git a/reference/forms/types/hidden.rst b/reference/forms/types/hidden.rst index 272eb853852..e211c526f63 100644 --- a/reference/forms/types/hidden.rst +++ b/reference/forms/types/hidden.rst @@ -1,8 +1,8 @@ .. index:: single: Forms; Fields; hidden -hidden Field Type -================= +HiddenType Field +================ The hidden type represents a hidden input field. @@ -18,7 +18,7 @@ The hidden type represents a hidden input field. | | - `mapped`_ | | | - `property_path`_ | +-------------+----------------------------------------------------------------------+ -| Parent type | :doc:`form ` | +| Parent type | :doc:`FormType ` | +-------------+----------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\HiddenType` | +-------------+----------------------------------------------------------------------+ @@ -45,8 +45,7 @@ Hidden fields cannot have a required attribute. Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/integer.rst b/reference/forms/types/integer.rst index b2d4348861e..19fff1d4e89 100644 --- a/reference/forms/types/integer.rst +++ b/reference/forms/types/integer.rst @@ -1,8 +1,8 @@ .. index:: - single: Forms; Fields; integer + single: Forms; Fields; IntegerType -integer Field Type -================== +IntegerType Field +================= Renders an input "number" field. Basically, this is a text field that's good at handling data that's in an integer form. The input ``number`` field @@ -36,7 +36,7 @@ integers. By default, all non-integer values (e.g. 6.78) will round down | | - `read_only`_ (deprecated as of 2.8) | | | - `required`_ | +-------------+-----------------------------------------------------------------------+ -| Parent type | :doc:`form ` | +| Parent type | :doc:`FormType ` | +-------------+-----------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\IntegerType` | +-------------+-----------------------------------------------------------------------+ @@ -85,8 +85,7 @@ Overridden Options Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/language.rst b/reference/forms/types/language.rst index 621dc08b3cd..aa2ea09b44f 100644 --- a/reference/forms/types/language.rst +++ b/reference/forms/types/language.rst @@ -1,10 +1,10 @@ .. index:: - single: Forms; Fields; language + single: Forms; Fields; LanguageType -language Field Type -=================== +LanguageType Field +================== -The ``language`` type is a subset of the ``ChoiceType`` that allows the +The ``LanguageType`` is a subset of the ``ChoiceType`` that allows the user to select from a large list of languages. As an added bonus, the language names are displayed in the language of the user. @@ -15,10 +15,9 @@ in the `International Components for Unicode`_ (e.g. ``fr`` or ``zh_Hant``). 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 a large list -of languages. 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 a large list of languages. 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`) | @@ -26,7 +25,7 @@ you should just use the ``choice`` type directly. | Overridden | - `choices`_ | | options | | +-------------+------------------------------------------------------------------------+ -| Inherited | from the :doc:`choice ` type | +| Inherited | from the :doc:`ChoiceType ` | | options | | | | - `placeholder`_ | | | - `error_bubbling`_ | @@ -35,7 +34,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `preferred_choices`_ | | | | -| | from the :doc:`form ` type | +| | from the :doc:`FormType ` | | | | | | - `data`_ | | | - `disabled`_ | @@ -46,7 +45,7 @@ you should just use the ``choice`` type directly. | | - `read_only`_ (deprecated as of 2.8) | | | - `required`_ | +-------------+------------------------------------------------------------------------+ -| Parent type | :doc:`choice ` | +| Parent type | :doc:`ChoiceType ` | +-------------+------------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\LanguageType` | +-------------+------------------------------------------------------------------------+ @@ -65,8 +64,7 @@ The default locale is used to translate the languages names. Inherited Options ----------------- -These options inherit from the :doc:`choice ` -type: +These options inherit from the :doc:`ChoiceType `: .. include:: /reference/forms/types/options/placeholder.rst.inc @@ -80,8 +78,7 @@ type: .. include:: /reference/forms/types/options/preferred_choices.rst.inc -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/locale.rst b/reference/forms/types/locale.rst index c1ddaf47ed0..83ae8acfa81 100644 --- a/reference/forms/types/locale.rst +++ b/reference/forms/types/locale.rst @@ -1,10 +1,10 @@ .. index:: - single: Forms; Fields; locale + single: Forms; Fields; LocaleType -locale Field Type -================= +LocaleType Field +================ -The ``locale`` type is a subset of the ``ChoiceType`` that allows the user +The ``LocaleType`` is a subset of the ``ChoiceType`` that allows the user to select from a large list of locales (language+country). As an added bonus, the locale names are displayed in the language of the user. @@ -17,10 +17,9 @@ for French/France). 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 a large list -of locales. 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 a large list of locales. You *can* specify these options +manually, but then you should just use the ``ChoiceType`` directly. +-------------+------------------------------------------------------------------------+ | Rendered as | can be various tags (see :ref:`forms-reference-choice-tags`) | @@ -28,7 +27,7 @@ you should just use the ``choice`` type directly. | Overridden | - `choices`_ | | options | | +-------------+------------------------------------------------------------------------+ -| Inherited | from the :doc:`choice ` type | +| Inherited | from the :doc:`ChoiceType ` | | options | | | | - `placeholder`_ | | | - `error_bubbling`_ | @@ -37,7 +36,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `preferred_choices`_ | | | | -| | from the :doc:`form ` type | +| | from the :doc:`FormType ` | | | | | | - `data`_ | | | - `disabled`_ | @@ -48,7 +47,7 @@ you should just use the ``choice`` type directly. | | - `read_only`_ (deprecated as of 2.8) | | | - `required`_ | +-------------+------------------------------------------------------------------------+ -| Parent type | :doc:`choice ` | +| Parent type | :doc:`ChoiceType ` | +-------------+------------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\LocaleType` | +-------------+------------------------------------------------------------------------+ @@ -67,8 +66,7 @@ specify the language. Inherited Options ----------------- -These options inherit from the :doc:`choice ` -type: +These options inherit from the :doc:`ChoiceType `: .. include:: /reference/forms/types/options/placeholder.rst.inc @@ -82,8 +80,7 @@ type: .. include:: /reference/forms/types/options/preferred_choices.rst.inc -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/map.rst.inc b/reference/forms/types/map.rst.inc index de0e07db282..4351908de8a 100644 --- a/reference/forms/types/map.rst.inc +++ b/reference/forms/types/map.rst.inc @@ -1,63 +1,63 @@ Text Fields ~~~~~~~~~~~ -* :doc:`text ` -* :doc:`textarea ` -* :doc:`email ` -* :doc:`integer ` -* :doc:`money ` -* :doc:`number ` -* :doc:`password ` -* :doc:`percent ` -* :doc:`search ` -* :doc:`url ` -* :doc:`range ` +* :doc:`TextType ` +* :doc:`TextareaType ` +* :doc:`EmailType ` +* :doc:`IntegerType ` +* :doc:`MoneyType ` +* :doc:`NumberType ` +* :doc:`PasswordType ` +* :doc:`PercentType ` +* :doc:`SearchType ` +* :doc:`UrlType ` +* :doc:`RangeType ` Choice Fields ~~~~~~~~~~~~~ -* :doc:`choice ` -* :doc:`entity ` -* :doc:`country ` -* :doc:`language ` -* :doc:`locale ` -* :doc:`timezone ` -* :doc:`currency ` +* :doc:`ChoiceType ` +* :doc:`EntityType ` +* :doc:`CountryType ` +* :doc:`LanguageType ` +* :doc:`LocaleType ` +* :doc:`TimezoneType ` +* :doc:`CurrencyType ` Date and Time Fields ~~~~~~~~~~~~~~~~~~~~ -* :doc:`date ` -* :doc:`datetime ` -* :doc:`time ` -* :doc:`birthday ` +* :doc:`DateType ` +* :doc:`DateTimeType ` +* :doc:`TimeType ` +* :doc:`BirthdayType ` Other Fields ~~~~~~~~~~~~ -* :doc:`checkbox ` -* :doc:`file ` -* :doc:`radio ` +* :doc:`CheckboxType ` +* :doc:`FileType ` +* :doc:`RadioType ` Field Groups ~~~~~~~~~~~~ -* :doc:`collection ` -* :doc:`repeated ` +* :doc:`CollectionType ` +* :doc:`RepeatedType ` Hidden Fields ~~~~~~~~~~~~~ -* :doc:`hidden ` +* :doc:`HiddenType ` Buttons ~~~~~~~ -* :doc:`button` -* :doc:`reset` -* :doc:`submit` +* :doc:`ButtonType ` +* :doc:`ResetType ` +* :doc:`SubmitType ` Base Fields ~~~~~~~~~~~ -* :doc:`form ` +* :doc:`FormType ` diff --git a/reference/forms/types/money.rst b/reference/forms/types/money.rst index a9683f02abc..f97dec52d51 100644 --- a/reference/forms/types/money.rst +++ b/reference/forms/types/money.rst @@ -1,8 +1,8 @@ .. index:: - single: Forms; Fields; money + single: Forms; Fields; MoneyType -money Field Type -================ +MoneyType Field +=============== Renders an input text field and specializes in handling submitted "money" data. @@ -35,7 +35,7 @@ how the input and output of the data is handled. | | - `read_only`_ (deprecated as of 2.8) | | | - `required`_ | +-------------+---------------------------------------------------------------------+ -| Parent type | :doc:`form ` | +| Parent type | :doc:`FormType ` | +-------------+---------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\MoneyType` | +-------------+---------------------------------------------------------------------+ @@ -65,7 +65,7 @@ If, for some reason, you need to divide your starting value by a number before rendering it to the user, you can use the ``divisor`` option. For example:: - use Symfony\Component\Form\Extension\Core\Type\FileType; + use Symfony\Component\Form\Extension\Core\Type\MoneyType; // ... $builder->add('price', MoneyType::class, array( @@ -101,8 +101,7 @@ Overridden Options Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/number.rst b/reference/forms/types/number.rst index 59094ac1bb9..3d67a154957 100644 --- a/reference/forms/types/number.rst +++ b/reference/forms/types/number.rst @@ -1,8 +1,8 @@ .. index:: - single: Forms; Fields; number + single: Forms; Fields; NumberType -number Field Type -================= +NumberType Field +================ Renders an input text field and specializes in handling number input. This type offers different options for the scale, rounding and grouping @@ -31,7 +31,7 @@ that you want to use for your number. | | - `read_only`_ (deprecated as of 2.8) | | | - `required`_ | +-------------+----------------------------------------------------------------------+ -| Parent type | :doc:`form ` | +| Parent type | :doc:`FormType ` | +-------------+----------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\NumberType` | +-------------+----------------------------------------------------------------------+ @@ -80,8 +80,7 @@ Overridden Options Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/password.rst b/reference/forms/types/password.rst index 3e971ff113f..f5db4f721be 100644 --- a/reference/forms/types/password.rst +++ b/reference/forms/types/password.rst @@ -1,10 +1,10 @@ .. index:: - single: Forms; Fields; password + single: Forms; Fields; PasswordType -password Field Type -=================== +PasswordType Field +================== -The ``password`` field renders an input password text box. +The ``PasswordType`` field renders an input password text box. +-------------+------------------------------------------------------------------------+ | Rendered as | ``input`` ``password`` field | @@ -25,7 +25,7 @@ The ``password`` field renders an input password text box. | | - `read_only`_ (deprecated as of 2.8) | | | - `required`_ | +-------------+------------------------------------------------------------------------+ -| Parent type | :doc:`text ` | +| Parent type | :doc:`TextType ` | +-------------+------------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType` | +-------------+------------------------------------------------------------------------+ @@ -54,7 +54,7 @@ trim **type**: ``boolean`` **default**: ``false`` -Unlike the rest of form types, the ``password`` type doesn't apply the +Unlike the rest of form types, the ``PasswordType`` doesn't apply the :phpfunction:`trim` function to the value submitted by the user. This ensures that the password is merged back onto the underlying object exactly as it was typed by the user. @@ -62,8 +62,7 @@ by the user. Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/disabled.rst.inc diff --git a/reference/forms/types/percent.rst b/reference/forms/types/percent.rst index 0efc8c7c2c2..14ad60281bf 100644 --- a/reference/forms/types/percent.rst +++ b/reference/forms/types/percent.rst @@ -1,11 +1,11 @@ .. index:: - single: Forms; Fields; percent + single: Forms; Fields; PercentType -percent Field Type -================== +PercentType Field +================= -The ``percent`` type renders an input text field and specializes in handling +The ``PercentType`` renders an input text field and specializes in handling percentage data. If your percentage data is stored as a decimal (e.g. ``.95``), you can use this field out-of-the-box. If you store your data as a number (e.g. ``95``), you should set the ``type`` option to ``integer``. @@ -34,7 +34,7 @@ This field adds a percentage sign "``%``" after the input box. | | - `read_only`_ (deprecated as of 2.8) | | | - `required`_ | +-------------+-----------------------------------------------------------------------+ -| Parent type | :doc:`form ` | +| Parent type | :doc:`FormType ` | +-------------+-----------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\PercentType` | +-------------+-----------------------------------------------------------------------+ @@ -82,8 +82,7 @@ Overridden Options Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/radio.rst b/reference/forms/types/radio.rst index b1adec4c6ea..cd7b0cc9d68 100644 --- a/reference/forms/types/radio.rst +++ b/reference/forms/types/radio.rst @@ -1,26 +1,26 @@ .. index:: - single: Forms; Fields; radio + single: Forms; Fields; RadioType -radio Field Type -================ +RadioType Field +=============== Creates a single radio button. If the radio button is selected, the field will be set to the specified value. Radio buttons cannot be unchecked - the value only changes when another radio button with the same name gets checked. -The ``radio`` type isn't usually used directly. More commonly it's used -internally by other types such as :doc:`choice `. -If you want to have a boolean field, use :doc:`checkbox `. +The ``RadioType`` isn't usually used directly. More commonly it's used +internally by other types such as :doc:`ChoiceType `. +If you want to have a boolean field, use :doc:`CheckboxType `. +-------------+---------------------------------------------------------------------+ | Rendered as | ``input`` ``radio`` field | +-------------+---------------------------------------------------------------------+ -| Inherited | from the :doc:`checkbox ` type: | +| Inherited | from the :doc:`CheckboxType `: | | options | | | | - `value`_ | | | | -| | from the :doc:`form ` type: | +| | from the :doc:`FormType `: | | | | | | - `data`_ | | | - `disabled`_ | @@ -33,7 +33,7 @@ If you want to have a boolean field, use :doc:`checkbox ` | +| Parent type | :doc:`CheckboxType ` | +-------------+---------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\RadioType` | +-------------+---------------------------------------------------------------------+ @@ -41,13 +41,11 @@ If you want to have a boolean field, use :doc:`checkbox ` -type: +These options inherit from the :doc:`CheckboxType `: .. include:: /reference/forms/types/options/value.rst.inc -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/range.rst b/reference/forms/types/range.rst index 0a1e8bb855a..a59082adb78 100644 --- a/reference/forms/types/range.rst +++ b/reference/forms/types/range.rst @@ -1,10 +1,10 @@ .. index:: - single: Forms; Fields; range + single: Forms; Fields; RangeType -range Field Type -================ +RangeType Field +=============== -The ``range`` field is a slider that is rendered using the HTML5 +The ``RangeType`` field is a slider that is rendered using the HTML5 ```` tag. +-------------+---------------------------------------------------------------------+ @@ -22,7 +22,7 @@ The ``range`` field is a slider that is rendered using the HTML5 | | - `required`_ | | | - `trim`_ | +-------------+---------------------------------------------------------------------+ -| Parent type | :doc:`text ` | +| Parent type | :doc:`TextType ` | +-------------+---------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\RangeType` | +-------------+---------------------------------------------------------------------+ @@ -45,8 +45,7 @@ Basic Usage Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/attr.rst.inc diff --git a/reference/forms/types/repeated.rst b/reference/forms/types/repeated.rst index b091cb33fb2..8c7bca02a87 100644 --- a/reference/forms/types/repeated.rst +++ b/reference/forms/types/repeated.rst @@ -1,8 +1,8 @@ .. index:: - single: Forms; Fields; repeated + single: Forms; Fields; RepeatedType -repeated Field Type -=================== +RepeatedType Field +================== This is a special field "group", that creates two identical fields whose values must match (or a validation error is thrown). The most common use @@ -28,7 +28,7 @@ accuracy. | | - `invalid_message_parameters`_ | | | - `mapped`_ | +-------------+------------------------------------------------------------------------+ -| Parent type | :doc:`form ` | +| Parent type | :doc:`FormType ` | +-------------+------------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType` | +-------------+------------------------------------------------------------------------+ @@ -39,10 +39,11 @@ Example Usage .. code-block:: php use Symfony\Component\Form\Extension\Core\Type\RepeatedType; + use Symfony\Component\Form\Extension\Core\Type\PasswordType; // ... $builder->add('password', RepeatedType::class, array( - 'type' => 'password', + 'type' => PasswordType::class, 'invalid_message' => 'The password fields must match.', 'options' => array('attr' => array('class' => 'password-field')), 'required' => true, @@ -58,7 +59,7 @@ single value (usually a string) that you need. The most important option is ``type``, which can be any field type and determines the actual type of the two underlying fields. The ``options`` option is passed to each of those individual fields, meaning - in this example - any -option supported by the ``password`` type can be passed in this array. +option supported by the ``PasswordType`` can be passed in this array. Rendering ~~~~~~~~~ @@ -120,7 +121,7 @@ first_name This is the actual field name to be used for the first field. This is mostly meaningless, however, as the actual data entered into both of the fields -will be available under the key assigned to the ``repeated`` field itself +will be available under the key assigned to the ``RepeatedType`` field itself (e.g. ``password``). However, if you don't specify a label, this field name is used to "guess" the label for you. @@ -150,7 +151,7 @@ This options array will be passed to each of the two underlying fields. In other words, these are the options that customize the individual field types. For example, if the ``type`` option is set to ``password``, this array might contain the options ``always_empty`` or ``required`` - both -options that are supported by the ``password`` field type. +options that are supported by the ``PasswordType`` field. second_name ~~~~~~~~~~~ @@ -174,7 +175,7 @@ type **type**: ``string`` **default**: ``text`` The two underlying fields will be of this field type. For example, passing -a type of ``password`` will render two password fields. +``PasswordType::class`` will render two password fields. Overridden Options ------------------ @@ -187,8 +188,7 @@ error_bubbling Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/reset.rst b/reference/forms/types/reset.rst index 20b2d9dad70..c3f7c215221 100644 --- a/reference/forms/types/reset.rst +++ b/reference/forms/types/reset.rst @@ -1,11 +1,11 @@ .. index:: - single: Forms; Fields; reset + single: Forms; Fields; ResetType -reset Field Type -================ +ResetType Field +=============== .. versionadded:: 2.3 - The ``reset`` type was introduced in Symfony 2.3 + The ``ResetType`` was introduced in Symfony 2.3 A button that resets all fields to their original values. @@ -18,7 +18,7 @@ A button that resets all fields to their original values. | | - `label_attr`_ | | | - `translation_domain`_ | +----------------------+---------------------------------------------------------------------+ -| Parent type | :doc:`button` | +| Parent type | :doc:`ButtonType ` | +----------------------+---------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\ResetType` | +----------------------+---------------------------------------------------------------------+ diff --git a/reference/forms/types/search.rst b/reference/forms/types/search.rst index 69f4f449734..52b23077768 100644 --- a/reference/forms/types/search.rst +++ b/reference/forms/types/search.rst @@ -1,8 +1,8 @@ .. index:: - single: Forms; Fields; search + single: Forms; Fields; SearchType -search Field Type -================= +SearchType Field +================ This renders an ```` field, which is a text box with special functionality supported by some browsers. @@ -24,7 +24,7 @@ Read about the input search field at `DiveIntoHTML5.info`_ | | - `required`_ | | | - `trim`_ | +-------------+----------------------------------------------------------------------+ -| Parent type | :doc:`text ` | +| Parent type | :doc:`TextType ` | +-------------+----------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\SearchType` | +-------------+----------------------------------------------------------------------+ @@ -32,8 +32,7 @@ Read about the input search field at `DiveIntoHTML5.info`_ Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/disabled.rst.inc diff --git a/reference/forms/types/submit.rst b/reference/forms/types/submit.rst index e8722f8dd0b..aa0d466f06b 100644 --- a/reference/forms/types/submit.rst +++ b/reference/forms/types/submit.rst @@ -1,11 +1,11 @@ .. index:: - single: Forms; Fields; submit + single: Forms; Fields; SubmitType -submit Field Type -================= +SubmitType Field +================ .. versionadded:: 2.3 - The ``submit`` type was introduced in Symfony 2.3 + The ``SubmitType`` type was introduced in Symfony 2.3 A submit button. @@ -19,7 +19,7 @@ A submit button. | | - `translation_domain`_ | | | - `validation_groups`_ | +----------------------+----------------------------------------------------------------------+ -| Parent type | :doc:`button` | +| Parent type | :doc:`ButtonType` | +----------------------+----------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\SubmitType` | +----------------------+----------------------------------------------------------------------+ diff --git a/reference/forms/types/text.rst b/reference/forms/types/text.rst index 38d1f784a8d..403d5556979 100644 --- a/reference/forms/types/text.rst +++ b/reference/forms/types/text.rst @@ -1,10 +1,10 @@ .. index:: - single: Forms; Fields; text + single: Forms; Fields; TextType -text Field Type -=============== +TextType Field +============== -The text field represents the most basic input text field. +The TextType field represents the most basic input text field. +-------------+--------------------------------------------------------------------+ | Rendered as | ``input`` ``text`` field | @@ -25,7 +25,7 @@ The text field represents the most basic input text field. | Overridden | - `compound`_ | | options | | +-------------+--------------------------------------------------------------------+ -| Parent type | :doc:`form ` | +| Parent type | :doc:`FormType ` | +-------------+--------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType` | +-------------+--------------------------------------------------------------------+ @@ -33,8 +33,7 @@ The text field represents the most basic input text field. Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/textarea.rst b/reference/forms/types/textarea.rst index 18ce38f4a4b..51d14af113e 100644 --- a/reference/forms/types/textarea.rst +++ b/reference/forms/types/textarea.rst @@ -1,8 +1,8 @@ .. index:: - single: Forms; Fields; textarea + single: Forms; Fields; TextareaType -textarea Field Type -=================== +TextareaType Field +================== Renders a ``textarea`` HTML element. @@ -23,7 +23,7 @@ Renders a ``textarea`` HTML element. | | - `required`_ | | | - `trim`_ | +-------------+------------------------------------------------------------------------+ -| Parent type | :doc:`text ` | +| Parent type | :doc:`TextType ` | +-------------+------------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\TextareaType` | +-------------+------------------------------------------------------------------------+ @@ -31,8 +31,7 @@ Renders a ``textarea`` HTML element. Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/attr.rst.inc diff --git a/reference/forms/types/time.rst b/reference/forms/types/time.rst index e3a4b405a5e..868555bddae 100644 --- a/reference/forms/types/time.rst +++ b/reference/forms/types/time.rst @@ -1,8 +1,8 @@ .. index:: - single: Forms; Fields; time + single: Forms; Fields; TimeType -time Field Type -=============== +TimeType Field +============== A field to capture time input. @@ -41,7 +41,7 @@ stored as a ``DateTime`` object, a string, a timestamp or an array. | | - `mapped`_ | | | - `read_only`_ (deprecated as of 2.8) | +----------------------+-----------------------------------------------------------------------------+ -| Parent type | form | +| Parent type | FormType | +----------------------+-----------------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\TimeType` | +----------------------+-----------------------------------------------------------------------------+ @@ -53,7 +53,7 @@ This field type is highly configurable, but easy to use. The most important options are ``input`` and ``widget``. Suppose that you have a ``startTime`` field whose underlying time data is -a ``DateTime`` object. The following configures the ``time`` type for that +a ``DateTime`` object. The following configures the ``TimeType`` for that field as two different choice fields:: use Symfony\Component\Form\Extension\Core\Type\TimeType; @@ -68,7 +68,7 @@ The ``input`` option *must* be changed to match the type of the underlying date data. For example, if the ``startTime`` field's data were a unix timestamp, you'd need to set ``input`` to ``timestamp``:: - use Symfony\Component\Form\Extension\Core\Type\ChoiceType; + use Symfony\Component\Form\Extension\Core\Type\TimeType; // ... $builder->add('startTime', TimeType::class, array( @@ -162,8 +162,7 @@ error_bubbling Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/timezone.rst b/reference/forms/types/timezone.rst index d23ba791b0b..835e7d719c7 100644 --- a/reference/forms/types/timezone.rst +++ b/reference/forms/types/timezone.rst @@ -1,19 +1,18 @@ .. index:: - single: Forms; Fields; timezone + single: Forms; Fields; TimezoneType -timezone Field Type -=================== +TimezoneType Field +================== -The ``timezone`` type is a subset of the ``ChoiceType`` that allows the +The ``TimezoneType`` is a subset of the ``ChoiceType`` that allows the user to select from all possible timezones. The "value" for each timezone is the full timezone name, such as ``America/Chicago`` or ``Europe/Istanbul``. -Unlike the ``choice`` type, you don't need to specify a ``choices`` or -``choice_list`` option as the field type automatically uses a large list -of timezones. 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 a large list of timezones. 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`) | @@ -21,14 +20,14 @@ you should just use the ``choice`` type directly. | Overridden | - `choices`_ | | options | | +-------------+------------------------------------------------------------------------+ -| Inherited | from the :doc:`choice ` type | +| Inherited | from the :doc:`ChoiceType ` | | options | | | | - `placeholder`_ | | | - `expanded`_ | | | - `multiple`_ | | | - `preferred_choices`_ | | | | -| | from the :doc:`form ` type | +| | from the :doc:`FormType ` | | | | | | - `data`_ | | | - `disabled`_ | @@ -41,7 +40,7 @@ you should just use the ``choice`` type directly. | | - `read_only`_ (deprecated as of 2.8) | | | - `required`_ | +-------------+------------------------------------------------------------------------+ -| Parent type | :doc:`choice ` | +| Parent type | :doc:`ChoiceType ` | +-------------+------------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\TimezoneType` | +-------------+------------------------------------------------------------------------+ @@ -52,7 +51,7 @@ Overridden Options choices ~~~~~~~ -**default**: :class:`Symfony\\Component\\Form\\Extension\\Core\\ChoiceList\\TimezoneChoiceList` +**default**: An array of timezones. The Timezone type defaults the choices to all timezones returned by :phpmethod:`DateTimeZone::listIdentifiers`, broken down by continent. @@ -60,8 +59,7 @@ The Timezone type defaults the choices to all timezones returned by Inherited Options ----------------- -These options inherit from the :doc:`choice ` -type: +These options inherit from the :doc:`ChoiceType `: .. include:: /reference/forms/types/options/placeholder.rst.inc @@ -71,8 +69,7 @@ type: .. include:: /reference/forms/types/options/preferred_choices.rst.inc -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc diff --git a/reference/forms/types/url.rst b/reference/forms/types/url.rst index ff4656dd6ed..e34ca991ebc 100644 --- a/reference/forms/types/url.rst +++ b/reference/forms/types/url.rst @@ -1,10 +1,10 @@ .. index:: - single: Forms; Fields; url + single: Forms; Fields; UrlType -url Field Type -============== +UrlType Field +============= -The ``url`` field is a text field that prepends the submitted value with +The ``UrlType`` field is a text field that prepends the submitted value with a given protocol (e.g. ``http://``) if the submitted value doesn't already have a protocol. @@ -26,7 +26,7 @@ have a protocol. | | - `required`_ | | | - `trim`_ | +-------------+-------------------------------------------------------------------+ -| Parent type | :doc:`text ` | +| Parent type | :doc:`TextType ` | +-------------+-------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\UrlType` | +-------------+-------------------------------------------------------------------+ @@ -46,8 +46,7 @@ the data is submitted to the form. Inherited Options ----------------- -These options inherit from the :doc:`form ` -type: +These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/data.rst.inc