diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index a5757116817..a275f77264a 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -111,7 +111,7 @@ 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. +With this option you can also allow float values to be selected as data. For example: .. code-block:: php @@ -119,9 +119,23 @@ With this option you can also allow float values to be selected as data. // ... $builder->add('status', 'choice', array( - 'choice_list' => new ChoiceList(array(1, 0.5), array('Full', 'Half')) + '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. + .. include:: /reference/forms/types/options/empty_value.rst.inc .. include:: /reference/forms/types/options/expanded.rst.inc