无法加载Type" Doctrine \ DBAL \ Types \ TextType"

时间:2017-06-23 13:35:23

标签: php symfony doctrine-orm doctrine

我使用get和set方法获得了所有值的Post实体

e.g。

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

在我的控制器中,我使用此类调用formBuilder

  /**
     * @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(),
        ));
    }

当我使用Route加载页面时出现此错误: 无法加载类型" Doctrine \ DBAL \ Types \ TextType"

1 个答案:

答案 0 :(得分:3)

将其添加到formBuilder文件的顶部

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