Skip to content

Commit 6af779d

Browse files
committed
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 4725f4f commit 6af779d

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
@@ -96,6 +96,23 @@ This is the property that should be used for displaying the entities
9696
as text in the HTML element. If left blank, the entity object will be
9797
cast into a string and so must have a ``__toString()`` method.
9898

99+
Note: ``property`` is the property path used to display the option. So you
100+
can use anything supported by the :doc:`PropertyAccessor component</components/property_access/introduction>`
101+
102+
Usage sample:
103+
104+
$builder->add('gender', 'entity', array(
105+
'class' => 'MyBundle:Gender',
106+
'property' => 'translations[en].name',
107+
'query_builder' => function(EntityRepository $er) {
108+
return $er->createQueryBuilder('g')
109+
->join('g.translations', 't')
110+
->where('t.locale = :locale')
111+
->orderBy('t.name', 'ASC')
112+
->setParameter('locale', 'en');
113+
},
114+
));
115+
99116
group_by
100117
~~~~~~~~
101118

0 commit comments

Comments
 (0)