I have tree main entity, User, Workgroup and Project. There is a middle entity called Collaboration beetween them. Actually I can provide a form to add a project with users information and workgroups information. I would to filter the workgroup by the connected user in the form.
There is a relation beetween User and Workgroup too, to know who's the owner of the workgroup. (User have One-to-Many on Workgroup and Workgroup have Many-to-one on user)
# MyNiceBundle/Form/Type/CollaborationType.php
class CollaborationType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('project', new ProjectType());
$builder->add('participant', 'entity', array(
'class' => 'MyNiceBundle:User',
'property' => 'email',
'multiple' => false,
'expanded' => true
));
$builder->add('workgroup', 'entity', array(
'class' => 'MyNiceBundle:Workgroup',
'property' => 'name',
'multiple' => false,
'expanded' => true
));
}
}
Thanks in advance.