最常见的解决方案是为(在您的情况下)创建单个表单:
然后,创建一个具有 userEntityFormType 和 ressellerEntityFormType 两个字段的新表单。
这样,您可以:
类似的东西
class UserEntityType extends AbstractType
{
public function BuildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('firstField')
->add('secondField')
[...]
->lastField;
}
public function getName()
{
return 'UserEntityType ';
}
}
class RessellerEntityType extends AbstractType
{
public function BuildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('firstField')
->add('secondField')
[...]
->lastField;
}
public function getName()
{
return 'RessellersEntityType ';
}
}
class AggregateEntityType extends AbstractType
{
public function BuildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('userEntityField',UserEntityType,array('multiple'=>true)
->add('ressellersEntityField',RessellersEntityType,array('multiple'=>true));
}
public function getName()
{
return 'AggregateEntityType ';
}
}