@@ -17,15 +17,15 @@ objects from the database.
17
17
| | - `em `_ |
18
18
| | - `query_builder `_ |
19
19
+-------------+------------------------------------------------------------------+
20
- | Overridden | - `choices `_ |
21
- | options | - `data_class `_ |
20
+ | Overridden | - `choice_name `_ |
21
+ | options | - `choice_value `_ |
22
+ | | - `choices `_ |
23
+ | | - `data_class `_ |
22
24
+-------------+------------------------------------------------------------------+
23
25
| Inherited | from the :doc: `choice </reference/forms/types/choice >` type: |
24
26
| options | |
25
27
| | - `choice_attr `_ |
26
- | | - `choice_name `_ |
27
28
| | - `choice_translation_domain `_ |
28
- | | - `choice_value `_ |
29
29
| | - `expanded `_ |
30
30
| | - `group_by `_ |
31
31
| | - `multiple `_ |
@@ -115,7 +115,7 @@ choice_label
115
115
The ``choice_label `` option was introduced in Symfony 2.7. Prior to Symfony
116
116
2.7, it was called ``property `` (which has the same functionality).
117
117
118
- **type **: ``string `` or `` callable ``
118
+ **type **: ``string ``, `` callable `` or :class: ` `Symfony \\ Component \\ PropertyAccess \\ PropertyPath ` `
119
119
120
120
This is the property that should be used for displaying the entities as text in
121
121
the HTML element::
@@ -183,6 +183,32 @@ the entity and return an instance of ``QueryBuilder``.
183
183
Overridden Options
184
184
------------------
185
185
186
+ choice_name
187
+ ~~~~~~~~~~~
188
+
189
+ .. versionadded :: 2.7
190
+ The ``choice_name `` option was introduced in Symfony 2.7.
191
+
192
+ **type **: ``string ``, ``callable `` or :class: ``Symfony\\ Component\\ PropertyAccess\\ PropertyPath` ` **default **: id
193
+
194
+ By default the name of each field will be the id of the entity, if it can be
195
+ get in the class metadata by an internal id reader.
196
+
197
+ choice_value
198
+ ~~~~~~~~~~~~
199
+
200
+ .. versionadded :: 2.7
201
+ The ``choice_value `` option was introduced in Symfony 2.7.
202
+
203
+ **type **: ``string ``, ``callable `` or :class: ``Symfony\\ Component\\ PropertyAccess\\ PropertyPath` ` **default **: id
204
+
205
+ As for the ``choice_name `` option, ``choice_value `` use the id by default.
206
+ It allows an optimization in the :class: ``Symfony\\ Bridge\\ Doctrine\\ Form\\ ChoiceList\\ Loader\\ DoctrineChoiceLoader` ` which will
207
+ only load the ids passed as values while the form submission, preventing the all class,
208
+ or even the custom ``query_builder `` to be called.
209
+ Even if it can be usefull for API to use an entity property as string value,
210
+ you will gain performances by letting this option set by default.
211
+
186
212
choices
187
213
~~~~~~~
188
214
@@ -208,12 +234,8 @@ type:
208
234
209
235
.. include :: /reference/forms/types/options/choice_attr.rst.inc
210
236
211
- .. include :: /reference/forms/types/options/choice_name.rst.inc
212
-
213
237
.. include :: /reference/forms/types/options/choice_translation_domain.rst.inc
214
238
215
- .. include :: /reference/forms/types/options/choice_value.rst.inc
216
-
217
239
.. include :: /reference/forms/types/options/expanded.rst.inc
218
240
219
241
.. include :: /reference/forms/types/options/group_by.rst.inc
0 commit comments