Skip to content

Commit 8eac7f3

Browse files
raziel057weaverryan
authored andcommitted
Add note about the property attribute (Property Accessor)
I think we must document the fact that propety is a path which is evaluted by the PropertyAccessor component.
1 parent bafd7ad commit 8eac7f3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

reference/forms/types/entity.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,23 @@ This is the property that should be used for displaying the entities
118118
as text in the HTML element. If left blank, the entity object will be
119119
cast into a string and so must have a ``__toString()`` method.
120120

121+
Note: ``property`` is the property path used to display the option. So you
122+
can use anything supported by the :doc:`PropertyAccessor component</components/property_access/introduction>`
123+
124+
Usage sample:
125+
126+
$builder->add('gender', 'entity', array(
127+
'class' => 'MyBundle:Gender',
128+
'property' => 'translations[en].name',
129+
'query_builder' => function(EntityRepository $er) {
130+
return $er->createQueryBuilder('g')
131+
->join('g.translations', 't')
132+
->where('t.locale = :locale')
133+
->orderBy('t.name', 'ASC')
134+
->setParameter('locale', 'en');
135+
},
136+
));
137+
121138
group_by
122139
~~~~~~~~
123140

0 commit comments

Comments
 (0)