I'm not sure if this solutions is best one, but it's working on one of my project, where I had similar problem.
You need to create FormType for each of Entity and correctly define data_class in setDefaultOptions method. In our example these are EventType and UserType.
For this to work, you need create class which represent both of entities. I call then Form Models.
// Acme\DemoBundle\Form\Model\Custom.php
class Custom
{
public $event;
public $user;
}
And now just create last FormType which glue this entities together in one form.
// Acme\DemoBundle\Form\CustomType.php
class CustomType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('Event', new EventType());
$builder->add('User', new UserType());
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Acme\DemoBundle\Form\Model\Custom'
));
}
...
}