Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"

like image 972
TNation Avatar asked Nov 25 '25 07:11

TNation


1 Answers

Add this at the top of your formBuilder file

use Symfony\Component\Form\Extension\Core\Type\TextType;
like image 88
Alessandro Minoccheri Avatar answered Nov 26 '25 19:11

Alessandro Minoccheri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!