diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index 6a2e7e619c5..556053c5336 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -13,19 +13,19 @@ To use this field, you must specify *either* ``choices`` or ``choice_loader`` op | Rendered as | can be various tags (see below) | +-------------+------------------------------------------------------------------------------+ | Options | - `choices`_ | -| | - `choices_as_values`_ | -| | - `choice_loader`_ | -| | - `choice_label`_ | | | - `choice_attr`_ | +| | - `choice_label`_ | +| | - `choice_list`_ (deprecated) | +| | - `choice_loader`_ | +| | - `choice_name`_ | | | - `choice_translation_domain`_ | -| | - `placeholder`_ | +| | - `choice_value`_ | +| | - `choices_as_values`_ | | | - `expanded`_ | +| | - `group_by`_ | | | - `multiple`_ | +| | - `placeholder`_ | | | - `preferred_choices`_ | -| | - `group_by`_ | -| | - `choice_value`_ | -| | - `choice_name`_ | -| | - `choice_list`_ (deprecated) | +-------------+------------------------------------------------------------------------------+ | Overridden | - `compound`_ | | options | - `empty_data`_ | @@ -172,6 +172,73 @@ is the item's label and the array value is the item's value:: 'choices_as_values' => true, )); +.. include:: /reference/forms/types/options/choice_attr.rst.inc + +.. _reference-form-choice-label: + +.. include:: /reference/forms/types/options/choice_label.rst.inc + +choice_list +~~~~~~~~~~~ + +.. caution:: + + The ``choice_list`` option of ChoiceType was deprecated in Symfony 2.7. + You should use `choices`_ or `choice_loader`_ now. + +**type**: :class:`Symfony\\Component\\Form\\Extension\\Core\\ChoiceList\\ChoiceListInterface` + +This is one way of specifying the options to be used for this field. +The ``choice_list`` option must be an instance of the ``ChoiceListInterface``. +For more advanced cases, a custom class that implements the interface +can be created to supply the choices. + +With this option you can also allow float values to be selected as data. +For example:: + + use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList; + + // ... + $builder->add('status', 'choice', array( + 'choice_list' => new ChoiceList( + array(1, 0.5, 0.1), + array('Full', 'Half', 'Almost empty') + ) + )); + +The ``status`` field created by the code above will be rendered as: + +.. code-block:: html + + + +But don't be confused! If ``Full`` is selected (value ``0`` in HTML), ``1`` +will be returned in your form. If ``Almost empty`` is selected (value ``2`` +in HTML), ``0.1`` will be returned. + +choice_loader +~~~~~~~~~~~~~ + +.. versionadded:: 2.7 + + The ``choice_loader`` option was added in Symfony 2.7. + +**type**: :class:`Symfony\\Component\\Form\\ChoiceList\\Loader\\ChoiceLoaderInterface` + +The ``choice_loader`` can be used to only partially load the choices in cases where +a fully-loaded list is not necessary. This is only needed in advanced cases and +would replace the ``choices`` option. + +.. include:: /reference/forms/types/options/choice_name.rst.inc + +.. include:: /reference/forms/types/options/choice_translation_domain.rst.inc + +.. include:: /reference/forms/types/options/choice_value.rst.inc + choices_as_values ~~~~~~~~~~~~~~~~~ @@ -213,83 +280,15 @@ type behaves as if it were set to true: 'choices' => array('Male' => 'm', 'Female' => 'f'), )); -choice_loader -~~~~~~~~~~~~~ - -.. versionadded:: 2.7 - - The ``choice_loader`` option was added in Symfony 2.7. - -**type**: :class:`Symfony\\Component\\Form\\ChoiceList\\Loader\\ChoiceLoaderInterface` - -The ``choice_loader`` can be used to only partially load the choices in cases where -a fully-loaded list is not necessary. This is only needed in advanced cases and -would replace the ``choices`` option. - -.. _reference-form-choice-label: - -.. include:: /reference/forms/types/options/choice_label.rst.inc - -.. include:: /reference/forms/types/options/choice_attr.rst.inc - -.. include:: /reference/forms/types/options/placeholder.rst.inc - -.. include:: /reference/forms/types/options/choice_translation_domain.rst.inc - .. include:: /reference/forms/types/options/expanded.rst.inc -.. include:: /reference/forms/types/options/multiple.rst.inc - -.. include:: /reference/forms/types/options/preferred_choices.rst.inc - .. include:: /reference/forms/types/options/group_by.rst.inc -.. include:: /reference/forms/types/options/choice_value.rst.inc - -.. include:: /reference/forms/types/options/choice_name.rst.inc - - -choice_list -~~~~~~~~~~~ - -.. caution:: - - The ``choice_list`` option of ChoiceType was deprecated in Symfony 2.7. - You should use `choices`_ or `choice_loader`_ now. - -**type**: :class:`Symfony\\Component\\Form\\Extension\\Core\\ChoiceList\\ChoiceListInterface` - -This is one way of specifying the options to be used for this field. -The ``choice_list`` option must be an instance of the ``ChoiceListInterface``. -For more advanced cases, a custom class that implements the interface -can be created to supply the choices. - -With this option you can also allow float values to be selected as data. -For example:: - - use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList; - - // ... - $builder->add('status', 'choice', array( - 'choice_list' => new ChoiceList( - array(1, 0.5, 0.1), - array('Full', 'Half', 'Almost empty') - ) - )); - -The ``status`` field created by the code above will be rendered as: - -.. code-block:: html +.. include:: /reference/forms/types/options/multiple.rst.inc - +.. include:: /reference/forms/types/options/placeholder.rst.inc -But don't be confused! If ``Full`` is selected (value ``0`` in HTML), ``1`` -will be returned in your form. If ``Almost empty`` is selected (value ``2`` -in HTML), ``0.1`` will be returned. +.. include:: /reference/forms/types/options/preferred_choices.rst.inc Overridden Options ------------------ diff --git a/reference/forms/types/country.rst b/reference/forms/types/country.rst index 405e598362b..4c4f3c436ea 100644 --- a/reference/forms/types/country.rst +++ b/reference/forms/types/country.rst @@ -27,11 +27,11 @@ you should just use the ``choice`` type directly. +-------------+-----------------------------------------------------------------------+ | Inherited | from the :doc:`choice ` type | | options | | -| | - `placeholder`_ | | | - `error_bubbling`_ | | | - `error_mapping`_ | | | - `expanded`_ | | | - `multiple`_ | +| | - `placeholder`_ | | | - `preferred_choices`_ | | | | | | from the :doc:`form ` type | @@ -68,8 +68,6 @@ Inherited Options These options inherit from the :doc:`choice ` type: -.. include:: /reference/forms/types/options/placeholder.rst.inc - .. include:: /reference/forms/types/options/error_bubbling.rst.inc .. include:: /reference/forms/types/options/error_mapping.rst.inc @@ -78,6 +76,8 @@ type: .. include:: /reference/forms/types/options/multiple.rst.inc +.. include:: /reference/forms/types/options/placeholder.rst.inc + .. include:: /reference/forms/types/options/preferred_choices.rst.inc These options inherit from the :doc:`form ` diff --git a/reference/forms/types/currency.rst b/reference/forms/types/currency.rst index 2a8dffd71e5..4ca2fdf72aa 100644 --- a/reference/forms/types/currency.rst +++ b/reference/forms/types/currency.rst @@ -21,10 +21,10 @@ you should just use the ``choice`` type directly. +-------------+------------------------------------------------------------------------+ | Inherited | from the :doc:`choice ` type | | options | | -| | - `placeholder`_ | | | - `error_bubbling`_ | | | - `expanded`_ | | | - `multiple`_ | +| | - `placeholder`_ | | | - `preferred_choices`_ | | | | | | from the :doc:`form ` type | @@ -60,14 +60,14 @@ Inherited Options These options inherit from the :doc:`choice` type: -.. include:: /reference/forms/types/options/placeholder.rst.inc - .. include:: /reference/forms/types/options/error_bubbling.rst.inc .. include:: /reference/forms/types/options/expanded.rst.inc .. include:: /reference/forms/types/options/multiple.rst.inc +.. include:: /reference/forms/types/options/placeholder.rst.inc + .. include:: /reference/forms/types/options/preferred_choices.rst.inc These options inherit from the :doc:`form` diff --git a/reference/forms/types/language.rst b/reference/forms/types/language.rst index 8f43a6bcc3c..6eb57950620 100644 --- a/reference/forms/types/language.rst +++ b/reference/forms/types/language.rst @@ -28,11 +28,11 @@ you should just use the ``choice`` type directly. +-------------+------------------------------------------------------------------------+ | Inherited | from the :doc:`choice ` type | | options | | -| | - `placeholder`_ | | | - `error_bubbling`_ | | | - `error_mapping`_ | | | - `expanded`_ | | | - `multiple`_ | +| | - `placeholder`_ | | | - `preferred_choices`_ | | | | | | from the :doc:`form ` type | @@ -69,8 +69,6 @@ Inherited Options These options inherit from the :doc:`choice ` type: -.. include:: /reference/forms/types/options/placeholder.rst.inc - .. include:: /reference/forms/types/options/error_bubbling.rst.inc .. include:: /reference/forms/types/options/error_mapping.rst.inc @@ -79,6 +77,8 @@ type: .. include:: /reference/forms/types/options/multiple.rst.inc +.. include:: /reference/forms/types/options/placeholder.rst.inc + .. include:: /reference/forms/types/options/preferred_choices.rst.inc These options inherit from the :doc:`form ` diff --git a/reference/forms/types/locale.rst b/reference/forms/types/locale.rst index 1fc34fc1520..a629c5ac4fe 100644 --- a/reference/forms/types/locale.rst +++ b/reference/forms/types/locale.rst @@ -30,11 +30,11 @@ you should just use the ``choice`` type directly. +-------------+------------------------------------------------------------------------+ | Inherited | from the :doc:`choice ` type | | options | | -| | - `placeholder`_ | | | - `error_bubbling`_ | | | - `error_mapping`_ | | | - `expanded`_ | | | - `multiple`_ | +| | - `placeholder`_ | | | - `preferred_choices`_ | | | | | | from the :doc:`form ` type | @@ -71,8 +71,6 @@ Inherited Options These options inherit from the :doc:`choice ` type: -.. include:: /reference/forms/types/options/placeholder.rst.inc - .. include:: /reference/forms/types/options/error_bubbling.rst.inc .. include:: /reference/forms/types/options/error_mapping.rst.inc @@ -81,6 +79,8 @@ type: .. include:: /reference/forms/types/options/multiple.rst.inc +.. include:: /reference/forms/types/options/placeholder.rst.inc + .. include:: /reference/forms/types/options/preferred_choices.rst.inc These options inherit from the :doc:`form ` diff --git a/reference/forms/types/timezone.rst b/reference/forms/types/timezone.rst index d527490c1db..cf937bf80a8 100644 --- a/reference/forms/types/timezone.rst +++ b/reference/forms/types/timezone.rst @@ -23,9 +23,9 @@ you should just use the ``choice`` type directly. +-------------+------------------------------------------------------------------------+ | Inherited | from the :doc:`choice ` type | | options | | -| | - `placeholder`_ | | | - `expanded`_ | | | - `multiple`_ | +| | - `placeholder`_ | | | - `preferred_choices`_ | | | | | | from the :doc:`form ` type | @@ -64,12 +64,12 @@ Inherited Options These options inherit from the :doc:`choice ` type: -.. include:: /reference/forms/types/options/placeholder.rst.inc - .. include:: /reference/forms/types/options/expanded.rst.inc .. include:: /reference/forms/types/options/multiple.rst.inc +.. include:: /reference/forms/types/options/placeholder.rst.inc + .. include:: /reference/forms/types/options/preferred_choices.rst.inc These options inherit from the :doc:`form `