I was intrigued, so I tested it myself and can confirm that it works
using an accessor.
Alternatively, you could modify the __toString() method which is used
by default if nothing is provided for the property value in the
options array.
// Form:
$this->add(new EntityChoiceField('salesRep', array(
'em' => $em,
'empty_value' => 'Select',
'class' => 'Sensio\HelloBundle\Entity\User',
'property' => 'fullname',
'query_builder' => function ($userRepository) {
return
$userRepository->createQueryBuilder('u')->where('u.active
= ?1')->setParameter(1, '1');
},
)));
// Entity:
public function getFullname()
{
return $this->getFirstname() . ' ' . $this->getLastname();
}
On Feb 15, 8:55 am, Bernhard Schussek <[email protected]> wrote:
> 2011/2/14 Damon Jones <[email protected]>:
>
> > Why not have a getFullname() accessor method in your user entity which
> > returns first and last name concatenated and use that property?
>
> This should work. If it doesn't, that's a bug.
>
> Bernhard
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en