Skip to content

Commit

Permalink
Add note about the property attribute (Property Accessor)
Browse files Browse the repository at this point in the history
I think we must document the fact that propety is a path which is evaluted by the PropertyAccessor component.
  • Loading branch information
raziel057 committed Oct 29, 2013
1 parent 4725f4f commit 6af779d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions reference/forms/types/entity.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,23 @@ This is the property that should be used for displaying the entities
as text in the HTML element. If left blank, the entity object will be
cast into a string and so must have a ``__toString()`` method.

Note: ``property`` is the property path used to display the option. So you
can use anything supported by the :doc:`PropertyAccessor component</components/property_access/introduction>`

Usage sample:

$builder->add('gender', 'entity', array(
'class' => 'MyBundle:Gender',
'property' => 'translations[en].name',
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('g')
->join('g.translations', 't')
->where('t.locale = :locale')
->orderBy('t.name', 'ASC')
->setParameter('locale', 'en');
},
));

group_by
~~~~~~~~

Expand Down

0 comments on commit 6af779d

Please sign in to comment.