Skip to content

Commit 3df5dd6

Browse files
committed
feature #5499 The "property" option of DoctrineType was deprecated. (XWB)
This PR was merged into the 2.7 branch. Discussion ---------- The "property" option of DoctrineType was deprecated. | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.7 | Fixed tickets | - Commits ------- cdb9067 The "property" option of DoctrineType was deprecated.
2 parents 90745db + cdb9067 commit 3df5dd6

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

reference/forms/types/entity.rst

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ objects from the database.
1212
+-------------+------------------------------------------------------------------+
1313
| Rendered as | can be various tags (see :ref:`forms-reference-choice-tags`) |
1414
+-------------+------------------------------------------------------------------+
15-
| Options | - `class`_ |
15+
| Options | - `choice_label`_ |
16+
| | - `class`_ |
1617
| | - `data_class`_ |
1718
| | - `em`_ |
1819
| | - `group_by`_ |
19-
| | - `property`_ |
2020
| | - `query_builder`_ |
2121
+-------------+------------------------------------------------------------------+
2222
| Overridden | - `choice_list`_ |
@@ -55,13 +55,13 @@ be listed inside the choice field::
5555

5656
$builder->add('users', 'entity', array(
5757
'class' => 'AcmeHelloBundle:User',
58-
'property' => 'username',
58+
'choice_label' => 'username',
5959
));
6060

6161
In this case, all ``User`` objects will be loaded from the database and
6262
rendered as either a ``select`` tag, a set or radio buttons or a series
6363
of checkboxes (this depends on the ``multiple`` and ``expanded`` values).
64-
If the entity object does not have a ``__toString()`` method the ``property``
64+
If the entity object does not have a ``__toString()`` method the ``choice_label``
6565
option is needed.
6666

6767
Using a Custom Query for the Entities
@@ -103,6 +103,29 @@ then you can supply the ``choices`` option directly::
103103
Field Options
104104
-------------
105105

106+
choice_label
107+
~~~~~~~~~~~~
108+
109+
**type**: ``string``
110+
111+
This is the property that should be used for displaying the entities
112+
as text in the HTML element. If left blank, the entity object will be
113+
cast into a string and so must have a ``__toString()`` method.
114+
115+
.. note::
116+
117+
The ``choice_label`` option is the property path used to display the option.
118+
So you can use anything supported by the
119+
:doc:`PropertyAccessor component </components/property_access/introduction>`
120+
121+
For example, if the translations property is actually an associative
122+
array of objects, each with a name property, then you could do this::
123+
124+
$builder->add('gender', 'entity', array(
125+
'class' => 'MyBundle:Gender',
126+
'choice_label' => 'translations[en].name',
127+
));
128+
106129
class
107130
~~~~~
108131

@@ -133,29 +156,6 @@ and does so by adding ``optgroup`` elements around options. Choices that
133156
do not return a value for this property path are rendered directly under
134157
the select tag, without a surrounding optgroup.
135158

136-
property
137-
~~~~~~~~
138-
139-
**type**: ``string``
140-
141-
This is the property that should be used for displaying the entities
142-
as text in the HTML element. If left blank, the entity object will be
143-
cast into a string and so must have a ``__toString()`` method.
144-
145-
.. note::
146-
147-
The ``property`` option is the property path used to display the option.
148-
So you can use anything supported by the
149-
:doc:`PropertyAccessor component </components/property_access/introduction>`
150-
151-
For example, if the translations property is actually an associative
152-
array of objects, each with a name property, then you could do this::
153-
154-
$builder->add('gender', 'entity', array(
155-
'class' => 'MyBundle:Gender',
156-
'property' => 'translations[en].name',
157-
));
158-
159159
query_builder
160160
~~~~~~~~~~~~~
161161

0 commit comments

Comments
 (0)