Form/Type/HiddenEntityType.php
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $transformer = new ObjectToIdentifierTransformer();
        $builder->addViewTransformer($transformer);

        if(0 === strlen($options['class'])) {
            $builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) use ($transformer) {
                $form = $event->getForm();
                $class = $form->getParent()->getConfig()->getDataClass();
                $property = $form->getName();
                if (null === $guessedType = $this->guesser->guessType($class, $property)) {
                    throw new \RuntimeException(sprintf('Unable to guess the type for "%s" property.', $property));
                }
                $typeOptions = $guessedType->getOptions();
                $repository = $this->om->getRepository($typeOptions['class']);
                $transformer->setRepository($repository);
            });
        } else {
            $repository = $this->om->getRepository($options['class']);
            $transformer->setRepository($repository);
        }

        $transformer->setIdentifier($options['identifier']);
    }
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $transformer = new ObjectToIdentifierTransformer();
        $builder->addViewTransformer($transformer);

        if(0 === strlen($options['class'])) {
            $builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) use ($transformer) {
                $form = $event->getForm();
                $class = $form->getParent()->getConfig()->getDataClass();
                $property = $form->getName();
                if (null === $guessedType = $this->guesser->guessType($class, $property)) {
                    throw new \RuntimeException(sprintf('Unable to guess the type for "%s" property.', $property));
                }
                $typeOptions = $guessedType->getOptions();
                $repository = $this->om->getRepository($typeOptions['class']);
                $transformer->setRepository($repository);
            });
        } else {
            $repository = $this->om->getRepository($options['class']);
            $transformer->setRepository($repository);
        }

        $transformer->setIdentifier($options['identifier']);
    }
{@inheritdoc}