0
我有一個擴展AbstractType的表單類。我的代碼如下...Symfony2表單類ContextErrorException
取FormBuilder並創建一個
$formFactory = $this->container->get('form.factory'); $builder = $formFactory->createBuilder('form', new MyEntity(), array());
呼叫的FormBuilder
$form = $builder->create(new MyType());
的create()
方法我在做什麼錯?該錯誤是如下...
ContextErrorException: Warning: array_key_exists(): The first argument should be either a string or an integer in C:\xampp\htdocs\icooicoo\vendor\symfony\symfony\src\Symfony\Component\Validator\Mapping\ClassMetadata.php line 289
此外,文檔中說,我應該通過$task
變量的create()
方法是任務實體對象但是該方法必須接受FormTypeInterface變量。
什麼是$ $ task變量?你的代碼只提示MyEntity和MyType?哪一個應該替代$任務? –