TNation
TNation

Reputation: 89

Could not load Type "Doctrine\DBAL\Types\TextType"

I got a Post Entity for all values, with get and set methods

e.g.

    /**
     * @var string
     *
     * @ORM\Column(name="autor", type="string", length=32)
     */
    private $autor;

In my controller I call the formBuilder with this class

  /**
     * @Route("/newPost", name="newPost")
     */
    public function newFormpostAction(Request $request)
    {
        // create a task and give it some dummy data for this example
        $nPost = new Posts();

        $form = $this->createFormBuilder($nPost)
            ->add('autor', TextType::class)
            ->add('titel', TextType::class)
            ->add('content', TextType::class)
            ->add('save', SubmitType::class, array('label' => 'Create Post'))
            ->getForm();

        return $this->render('default/newPost.html.twig', array(
            'form' => $form->createView(),
        ));
    }

When I load up the page with the Route I get this error: Could not load type "Doctrine\DBAL\Types\TextType"

Upvotes: 3

Views: 2642

Answers (1)

Alessandro Minoccheri
Alessandro Minoccheri

Reputation: 35963

Add this at the top of your formBuilder file

use Symfony\Component\Form\Extension\Core\Type\TextType;

Upvotes: 4

Related Questions