Skip to content

Commit 3923c41

Browse files
committed
[reference][form] Adding missing details to entity type. This closes #399
1 parent 8879582 commit 3923c41

File tree

4 files changed

+48
-42
lines changed

4 files changed

+48
-42
lines changed

reference/forms/types/choice.rst

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -64,49 +64,9 @@ specify the choices for your widget.
6464

6565
.. _forms-reference-choice-tags:
6666

67-
Select tag, Checkboxes or Radio Buttons
68-
---------------------------------------
67+
.. include:: /reference/forms/types/options/select_how_rendered.rst.inc
6968

70-
This field may be rendered as one of several different HTML fields, depending
71-
on the ``expanded`` and ``multiple`` options:
72-
73-
+------------------------------------------+----------+----------+
74-
| element type | expanded | multiple |
75-
+==========================================+==========+==========+
76-
| select tag | false | false |
77-
+------------------------------------------+----------+----------+
78-
| select tag (with ``multiple`` attribute) | false | true |
79-
+------------------------------------------+----------+----------+
80-
| radio buttons | true | false |
81-
+------------------------------------------+----------+----------+
82-
| checkboxes | true | true |
83-
+------------------------------------------+----------+----------+
84-
85-
Adding an "empty value"
86-
-----------------------
87-
88-
If you're using the non-expanded version of the type (i.e. a ``select`` tag)
89-
element and you'd like to have a blank entry (e.g. "Choose an option") at
90-
the top of the select box, you can easily do so by doing the following:
91-
92-
* Set the ``multiple`` option to false;
93-
94-
* Set the ``required`` option to false or explicitly pass in the ``empty_value``
95-
option in the template (as shown below).
96-
97-
If ``required`` is true, a blank choice will display at the top of the select
98-
box. To customize what that entry says (or if you have ``required`` set to
99-
``false``), add the following when rendering the field:
100-
101-
.. configuration-block::
102-
103-
.. code-block:: jinja
104-
105-
{{ form_widget(form.foo_choices, { 'empty_value': 'Choose an option' }) }}
106-
107-
.. code-block:: php
108-
109-
<?php echo $view['form']->widget($form['foo_choices'], array('empty_value' => 'Choose an option')) ?>
69+
.. include:: /reference/forms/types/options/empty_value.rst.inc
11070

11171
Options
11272
-------

reference/forms/types/entity.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ option. The easiest way to use the option is as follows::
6262
},
6363
));
6464

65+
.. include:: /reference/forms/types/options/select_how_rendered.rst.inc
66+
67+
.. include:: /reference/forms/types/options/empty_value.rst.inc
68+
6569
Options
6670
-------
6771

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Adding an "empty value"
2+
-----------------------
3+
4+
If you're using the non-expanded version of the type (i.e. a ``select`` tag)
5+
element and you'd like to have a blank entry (e.g. "Choose an option") at
6+
the top of the select box, you can easily do so by doing the following:
7+
8+
* Set the ``multiple`` option to false;
9+
10+
* Set the ``required`` option to false or explicitly pass in the ``empty_value``
11+
option in the template (as shown below).
12+
13+
If ``required`` is true, a blank choice will display at the top of the select
14+
box. To customize what that entry says (or if you have ``required`` set to
15+
``false``), add the following when rendering the field:
16+
17+
.. configuration-block::
18+
19+
.. code-block:: jinja
20+
21+
{{ form_widget(form.foo_choices, { 'empty_value': 'Choose an option' }) }}
22+
23+
.. code-block:: php
24+
25+
<?php echo $view['form']->widget($form['foo_choices'], array('empty_value' => 'Choose an option')) ?>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Select tag, Checkboxes or Radio Buttons
2+
---------------------------------------
3+
4+
This field may be rendered as one of several different HTML fields, depending
5+
on the ``expanded`` and ``multiple`` options:
6+
7+
+------------------------------------------+----------+----------+
8+
| element type | expanded | multiple |
9+
+==========================================+==========+==========+
10+
| select tag | false | false |
11+
+------------------------------------------+----------+----------+
12+
| select tag (with ``multiple`` attribute) | false | true |
13+
+------------------------------------------+----------+----------+
14+
| radio buttons | true | false |
15+
+------------------------------------------+----------+----------+
16+
| checkboxes | true | true |
17+
+------------------------------------------+----------+----------+

0 commit comments

Comments
 (0)