I can do $this->createForm(new EntityType(), $entity, array('em' => $em))
from the controller, but how can I pass it to a NestedEntityType()
? I guess I can't just pass it on from inside the EntityType->buildForm()
:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$entityManager = $options['em'];
$builder->add('entities', 'collection', array(
'type' => new NestedEntityType(),
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false
));
}
I need the entity manager to setup a data transformer to check if an entity already exists in the database, and use that entity in a relationship instead of creating a new one with the same name.
Resources