@@ -17,15 +17,15 @@ objects from the database.
1717| | - `em `_ |
1818| | - `query_builder `_ |
1919+-------------+------------------------------------------------------------------+
20- | Overridden | - `choices `_ |
21- | options | - `data_class `_ |
20+ | Overridden | - `choice_name `_ |
21+ | options | - `choice_value `_ |
22+ | | - `choices `_ |
23+ | | - `data_class `_ |
2224+-------------+------------------------------------------------------------------+
2325| Inherited | from the :doc: `choice </reference/forms/types/choice >` type: |
2426| options | |
2527| | - `choice_attr `_ |
26- | | - `choice_name `_ |
2728| | - `choice_translation_domain `_ |
28- | | - `choice_value `_ |
2929| | - `expanded `_ |
3030| | - `group_by `_ |
3131| | - `multiple `_ |
@@ -115,7 +115,7 @@ choice_label
115115 The ``choice_label `` option was introduced in Symfony 2.7. Prior to Symfony
116116 2.7, it was called ``property `` (which has the same functionality).
117117
118- **type **: ``string `` or ``callable ``
118+ **type **: ``string ``, ``callable `` or :class: ` Symfony \\ Component \\ PropertyAccess \\ PropertyPath `
119119
120120This is the property that should be used for displaying the entities as text in
121121the HTML element::
@@ -183,6 +183,32 @@ the entity and return an instance of ``QueryBuilder``.
183183Overridden Options
184184------------------
185185
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 is the id of the entity, if it can be get in
195+ 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 all entities,
208+ even with a custom ``query_builder `` to be loaded.
209+ If it can be usefull for API to use an entity property as string value, you
210+ will gain performances by letting this option set by default.
211+
186212choices
187213~~~~~~~
188214
@@ -208,12 +234,8 @@ type:
208234
209235.. include :: /reference/forms/types/options/choice_attr.rst.inc
210236
211- .. include :: /reference/forms/types/options/choice_name.rst.inc
212-
213237.. include :: /reference/forms/types/options/choice_translation_domain.rst.inc
214238
215- .. include :: /reference/forms/types/options/choice_value.rst.inc
216-
217239.. include :: /reference/forms/types/options/expanded.rst.inc
218240
219241.. include :: /reference/forms/types/options/group_by.rst.inc
0 commit comments