I have 3 entities:
[Member] ----OneToMany----> [MemberCategory] ---ManyToOne---> [Category]
This works well as far as fetching results fr
This is how I resolved this problem in the past (applied to your example) but this is what I figured out so it might not be 100% right for your case.
First create a MemberCategory
form type matching your needs:
add('priority')
->add('category', 'entity',
array('property' => 'name',
'class' => 'CompanyYourBundle:Category'))
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Company\YourBundle\Entity\MemberCategory'
));
}
public function getName()
{
return 'company_yourbundle_membercategorytype';
}
}
Then add this form type inside your Member
type form:
add('name')
->add('members', 'collection', array(
'type' => new MemberCategoryType(),
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,));
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Company\YourBundle\Entity\Member'
));
}
public function getName()
{
return 'company_yourbundle_membertype';
}
}
Then you can follow the documentation to add as many categories as you want to your members and assigning a priority every time.