8000 Improved description of choice_list option by javiereguiluz · Pull Request #5428 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content
8000

Improved description of choice_list option #5428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 23, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
improved description of choice_list option of Choice form type
  • Loading branch information
azielinski committed Mar 2, 2015
commit 5bc5969903e755af3a6811af3e1c63e1ee02b33c
14 changes: 12 additions & 2 deletions reference/forms/types/choice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,27 @@ 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

use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList;

// ...
$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

<select name="status">
<option value="0">Full</option>
<option value="1">Half</option>
<option value="2">Almost empty</option>
</select>

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

.. include:: /reference/forms/types/options/expanded.rst.inc
Expand Down
0