Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bc70d00

Browse files
committed
minor #6262 [Form] reorder options in choice types references (HeahDude)
This PR was merged into the 2.7 branch. Discussion ---------- [Form] reorder options in choice types references | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.7+ | Fixed tickets | #6261 Commits ------- 3eda649 reorder options in choice types references
2 parents ebe0724 + 3eda649 commit bc70d00

File tree

6 files changed

+93
-94
lines changed

6 files changed

+93
-94
lines changed

reference/forms/types/choice.rst

Lines changed: 78 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ To use this field, you must specify *either* ``choices`` or ``choice_loader`` op
1313
| Rendered as | can be various tags (see below) |
1414
+-------------+------------------------------------------------------------------------------+
1515
| Options | - `choices`_ |
16-
| | - `choices_as_values`_ |
17-
| | - `choice_loader`_ |
18-
| | - `choice_label`_ |
1916
| | - `choice_attr`_ |
17+
| | - `choice_label`_ |
18+
| | - `choice_list`_ (deprecated) |
19+
| | - `choice_loader`_ |
20+
| | - `choice_name`_ |
2021
| | - `choice_translation_domain`_ |
21-
| | - `placeholder`_ |
22+
| | - `choice_value`_ |
23+
| | - `choices_as_values`_ |
2224
| | - `expanded`_ |
25+
| | - `group_by`_ |
2326
| | - `multiple`_ |
27+
| | - `placeholder`_ |
2428
| | - `preferred_choices`_ |
25-
| | - `group_by`_ |
26-
| | - `choice_value`_ |
27-
| | - `choice_name`_ |
28-
| | - `choice_list`_ (deprecated) |
2929
+-------------+------------------------------------------------------------------------------+
3030
| Overridden | - `compound`_ |
3131
| options | - `empty_data`_ |
@@ -172,6 +172,73 @@ is the item's label and the array value is the item's value::
172172
'choices_as_values' => true,
173173
));
174174

175+
.. include:: /reference/forms/types/options/choice_attr.rst.inc
176+
177+
.. _reference-form-choice-label:
178+
179+
.. include:: /reference/forms/types/options/choice_label.rst.inc
180+
181+
choice_list
182+
~~~~~~~~~~~
183+
184+
.. caution::
185+
186+
The ``choice_list`` option of ChoiceType was deprecated in Symfony 2.7.
187+
You should use `choices`_ or `choice_loader`_ now.
188+
189+
**type**: :class:`Symfony\\Component\\Form\\Extension\\Core\\ChoiceList\\ChoiceListInterface`
190+
191+
This is one way of specifying the options to be used for this field.
192+
The ``choice_list`` option must be an instance of the ``ChoiceListInterface``.
193+
For more advanced cases, a custom class that implements the interface
194+
can be created to supply the choices.
195+
196+
With this option you can also allow float values to be selected as data.
197+
For example::
198+
199+
use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList;
200+
201+
// ...
202+
$builder->add('status', 'choice', array(
203+
'choice_list' => new ChoiceList(
204+
array(1, 0.5, 0.1),
205+
array('Full', 'Half', 'Almost empty')
206+
)
207+
));
208+
209+
The ``status`` field created by the code above will be rendered as:
210+
211+
.. code-block:: html
212+
213+
<select name="status">
214+
<option value="0">Full</option>
215+
<option value="1">Half</option>
216+
<option value="2">Almost empty</option>
217+
</select>
218+
219+
But don't be confused! If ``Full`` is selected (value ``0`` in HTML), ``1``
220+
will be returned in your form. If ``Almost empty`` is selected (value ``2``
221+
in HTML), ``0.1`` will be returned.
222+
223+
choice_loader
224+
~~~~~~~~~~~~~
225+
226+
.. versionadded:: 2.7
227+
228+
The ``choice_loader`` option was added in Symfony 2.7.
229+
230+
**type**: :class:`Symfony\\Component\\Form\\ChoiceList\\Loader\\ChoiceLoaderInterface`
231+
232+
The ``choice_loader`` can be used to only partially load the choices in cases where
233+
a fully-loaded list is not necessary. This is only needed in advanced cases and
234+
would replace the ``choices`` option.
235+
236+
.. include:: /reference/forms/types/options/choice_name.rst.inc
237+
238+
.. include:: /reference/forms/types/options/choice_translation_domain.rst.inc
239+
240+
.. include:: /reference/forms/types/options/choice_value.rst.inc
241+
175242
choices_as_values
176243
~~~~~~~~~~~~~~~~~
177244

@@ -213,83 +280,15 @@ type behaves as if it were set to true:
213280
'choices' => array('Male' => 'm', 'Female' => 'f'),
214281
));
215282

216-
choice_loader
217-
~~~~~~~~~~~~~
218-
219-
.. versionadded:: 2.7
220-
221-
The ``choice_loader`` option was added in Symfony 2.7.
222-
223-
**type**: :class:`Symfony\\Component\\Form\\ChoiceList\\Loader\\ChoiceLoaderInterface`
224-
225-
The ``choice_loader`` can be used to only partially load the choices in cases where
226-
a fully-loaded list is not necessary. This is only needed in advanced cases and
227-
would replace the ``choices`` option.
228-
229-
.. _reference-form-choice-label:
230-
231-
.. include:: /reference/forms/types/options/choice_label.rst.inc
232-
233-
.. include:: /reference/forms/types/options/choice_attr.rst.inc
234-
235-
.. include:: /reference/forms/types/options/placeholder.rst.inc
236-
237-
.. include:: /reference/forms/types/options/choice_translation_domain.rst.inc
238-
239283
.. include:: /reference/forms/types/options/expanded.rst.inc
240284

241-
.. include:: /reference/forms/types/options/multiple.rst.inc
242-
243-
.. include:: /reference/forms/types/options/preferred_choices.rst.inc
244-
245285
.. include:: /reference/forms/types/options/group_by.rst.inc
246286

247-
.. include:: /reference/forms/types/options/choice_value.rst.inc
248-
249-
.. include:: /reference/forms/types/options/choice_name.rst.inc
250-
251-
252-
choice_list
253-
~~~~~~~~~~~
254-
255-
.. caution::
256-
257-
The ``choice_list`` option of ChoiceType was deprecated in Symfony 2.7.
258-
You should use `choices`_ or `choice_loader`_ now.
259-
260-
**type**: :class:`Symfony\\Component\\Form\\Extension\\Core\\ChoiceList\\ChoiceListInterface`
261-
262-
This is one way of specifying the options to be used for this field.
263-
The ``choice_list`` option must be an instance of the ``ChoiceListInterface``.
264-
For more advanced cases, a custom class that implements the interface
265-
can be created to supply the choices.
266-
267-
With this option you can also allow float values to be selected as data.
268-
For example::
269-
270-
use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList;
271-
272-
// ...
273-
$builder->add('status', 'choice', array(
274-
'choice_list' => new ChoiceList(
275-
array(1, 0.5, 0.1),
276-
array('Full', 'Half', 'Almost empty')
277-
)
278-
));
279-
280-
The ``status`` field created by the code above will be rendered as:
281-
282-
.. code-block:: html
287+
.. include:: /reference/forms/types/options/multiple.rst.inc
283288

284-
<select name="status">
285-
<option value="0">Full</option>
286-
<option value="1">Half</option>
287-
<option value="2">Almost empty</option>
288-
</select>
289+
.. include:: /reference/forms/types/options/placeholder.rst.inc
289290

290-
But don't be confused! If ``Full`` is selected (value ``0`` in HTML), ``1``
291-
will be returned in your form. If ``Almost empty`` is selected (value ``2``
292-
in HTML), ``0.1`` will be returned.
291+
.. include:: /reference/forms/types/options/preferred_choices.rst.inc
293292

294293
Overridden Options
295294
------------------

reference/forms/types/country.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ you should just use the ``choice`` type directly.
2727
+-------------+-----------------------------------------------------------------------+
2828
| Inherited | from the :doc:`choice </reference/forms/types/choice>` type |
2929
| options | |
30-
| | - `placeholder`_ |
3130
| | - `error_bubbling`_ |
3231
| | - `error_mapping`_ |
3332
| | - `expanded`_ |
3433
| | - `multiple`_ |
34+
| | - `placeholder`_ |
3535
| | - `preferred_choices`_ |
3636
| | |
3737
| | from the :doc:`form </reference/forms/types/form>` type |
@@ -68,8 +68,6 @@ Inherited Options
6868
These options inherit from the :doc:`choice </reference/forms/types/choice>`
6969
type:
7070

71-
.. include:: /reference/forms/types/options/placeholder.rst.inc
72-
7371
.. include:: /reference/forms/types/options/error_bubbling.rst.inc
7472

7573
.. include:: /reference/forms/types/options/error_mapping.rst.inc
@@ -78,6 +76,8 @@ type:
7876

7977
.. include:: /reference/forms/types/options/multiple.rst.inc
8078

79+
.. include:: /reference/forms/types/options/placeholder.rst.inc
80+
8181
.. include:: /reference/forms/types/options/preferred_choices.rst.inc
8282

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

reference/forms/types/currency.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ you should just use the ``choice`` type directly.
2121
+-------------+------------------------------------------------------------------------+
2222
| Inherited | from the :doc:`choice </reference/forms/types/choice>` type |
2323
| options | |
24-
| | - `placeholder`_ |
2524
| | - `error_bubbling`_ |
2625
| | - `expanded`_ |
2726
| | - `multiple`_ |
27+
| | - `placeholder`_ |
2828
| | - `preferred_choices`_ |
2929
| | |
3030
| | from the :doc:`form </reference/forms/types/form>` type |
@@ -60,14 +60,14 @@ Inherited Options
6060
These options inherit from the :doc:`choice</reference/forms/types/choice>`
6161
type:
6262

63-
.. include:: /reference/forms/types/options/placeholder.rst.inc
64-
6563
.. include:: /reference/forms/types/options/error_bubbling.rst.inc
6664

6765
.. include:: /reference/forms/types/options/expanded.rst.inc
6866

6967
.. include:: /reference/forms/types/options/multiple.rst.inc
7068

69+
.. include:: /reference/forms/types/options/placeholder.rst.inc
70+
7171
.. include:: /reference/forms/types/options/preferred_choices.rst.inc
7272

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

reference/forms/types/language.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ you should just use the ``choice`` type directly.
2828
+-------------+------------------------------------------------------------------------+
2929
| Inherited | from the :doc:`choice </reference/forms/types/choice>` type |
3030
| options | |
31-
| | - `placeholder`_ |
3231
| | - `error_bubbling`_ |
3332
| | - `error_mapping`_ |
3433
| | - `expanded`_ |
3534
| | - `multiple`_ |
35+
| | - `placeholder`_ |
3636
| | - `preferred_choices`_ |
3737
| | |
3838
| | from the :doc:`form </reference/forms/types/form>` type |
@@ -69,8 +69,6 @@ Inherited Options
6969
These options inherit from the :doc:`choice </reference/forms/types/choice>`
7070
type:
7171

72-
.. include:: /reference/forms/types/options/placeholder.rst.inc
73-
7472
.. include:: /reference/forms/types/options/error_bubbling.rst.inc
7573

7674
.. include:: /reference/forms/types/options/error_mapping.rst.inc
@@ -79,6 +77,8 @@ type:
7977

8078
.. include:: /reference/forms/types/options/multiple.rst.inc
8179

80+
.. include:: /reference/forms/types/options/placeholder.rst.inc
81+
8282
.. include:: /reference/forms/types/options/preferred_choices.rst.inc
8383

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

reference/forms/types/locale.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ you should just use the ``choice`` type directly.
3030
+-------------+------------------------------------------------------------------------+
3131
| Inherited | from the :doc:`choice </reference/forms/types/choice>` type |
3232
| options | |
33-
| | - `placeholder`_ |
3433
| | - `error_bubbling`_ |
3534
| | - `error_mapping`_ |
3635
| | - `expanded`_ |
3736
| | - `multiple`_ |
37+
| | - `placeholder`_ |
3838
| | - `preferred_choices`_ |
3939
| | |
4040
| | from the :doc:`form </reference/forms/types/form>` type |
@@ -71,8 +71,6 @@ Inherited Options
7171
These options inherit from the :doc:`choice </reference/forms/types/choice>`
7272
type:
7373

74-
.. include:: /reference/forms/types/options/placeholder.rst.inc
75-
7674
.. include:: /reference/forms/types/options/error_bubbling.rst.inc
7775

7876
.. include:: /reference/forms/types/options/error_mapping.rst.inc
@@ -81,6 +79,8 @@ type:
8179

8280
.. include:: /reference/forms/types/options/multiple.rst.inc
8381

82+
.. include:: /reference/forms/types/options/placeholder.rst.inc
83+
8484
.. include:: /reference/forms/types/options/preferred_choices.rst.inc
8585

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

reference/forms/types/timezone.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ you should just use the ``choice`` type directly.
2323
+-------------+------------------------------------------------------------------------+
2424
| Inherited | from the :doc:`choice </reference/forms/types/choice>` type |
2525
| options | |
26-
| | - `placeholder`_ |
2726
| | - `expanded`_ |
2827
| | - `multiple`_ |
28+
| | - `placeholder`_ |
2929
| | - `preferred_choices`_ |
3030
| | |
3131
| | from the :doc:`form </reference/forms/types/form>` type |
@@ -64,12 +64,12 @@ Inherited Options
6464
These options inherit from the :doc:`choice </reference/forms/types/choice>`
6565
type:
6666

67-
.. include:: /reference/forms/types/options/placeholder.rst.inc
68-
6967
.. include:: /reference/forms/types/options/expanded.rst.inc
7068

7169
.. include:: /reference/forms/types/options/multiple.rst.inc
7270

71+
.. include:: /reference/forms/types/options/placeholder.rst.inc
72+
7373
.. include:: /reference/forms/types/options/preferred_choices.rst.inc
7474

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

0 commit comments

Comments
 (0)