書籍「基本からしっかり学ぶ Symfony2入門」を読みながらSymfonyの勉強をしています。
テキストどおりにコーディングしていたら次のエラーが発生しました。
Could not load type "text"
調べてみるとSymfony2から3での変更によるもので、Symfonyのバージョンはテキストでは2、自分の環境では3でした。
エラーを解決するために下記ソースで「★」の部分を追記・修正しましたが、次のエラーが発生してしまいます。
Could not load type "TextType::class"
このエラーを解決するにはどうすればよいでしょうか?
もしくは、Symfony3から2へのダウングレードの方法がわかればベターです。
(EC-CUBE3の勉強のためにSymfony2を学びたいため)
[環境]
Symfony version 3.1.4
[ソース]
<?php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\Form\Extension\Core\Type\TextType; // ★
/**
* @Route("/Inquiry")
*/
class InquiryController extends Controller
{
/**
* @Route("/")
* @Method("get")
*/
public function indexAction()
{
$form = $this->createFormBuilder()
->add('name', 'TextType::class') // ★
->add('email', 'TextType::class') // ★
->add('tel', 'TextType::class', [ // ★
'required' => false,
])
->getForm();
return $this->render('Inquiry/index.html.twig',
['form' => $form->createView()]
);
}
}