I have a controller that displays a form that is supposed to have a drop-down list with headers mapped to the client_user object. Below is the code that I use in my controller to create the form:
$builder = $this->get(form.factory);
$em = $this->get('doctrine.entity_manager');
$form = $builder->createBuilder(new ClientUserType($em), new ClientUser())->getForm();
Below is my ClientUserType class with a constructor that I pass to the entity manager:
<?php
namespace Application\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
class ClientUserType extends AbstractType
{
protected $entityManager;
public function __construct($entityManager)
{
$this->entityManager = $entityManager;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', EntityType::class, array(
'class' => '\\Application\\Model\\Entity\\Title',
'em' => $this->entityManager
))
->add('name')
->add('surname')
->add('contact')
->add('email');
}
public function getName()
{
return 'client_user_form';
}
}
I keep getting this fascinating fatal error below and don’t know what I need to do to get a drop-down list with headers from the doctrine database.
: 1 Symfony\Bridge\Doctrine\Form\Type\DoctrineType:: __ construct() Doctrine\Common\Persistence\ManagerRegistry, , D:\web\ \vendor\symfony\form\FormRegistry.php 90 D:\web\playground-solutions\vendor\symfony\doctrine-bridge\Form\Type\DoctrineType.php 111
. , DirectorRegistry, , , . , , , ManagerRegistry .
- ? ?