【发布时间】:2012-03-21 10:47:33
【问题描述】:
我正在关注 Symfony2 的 the tutorial,了解如何使用表单类。
我做错了,因为当我使用以下示例代码时:
// src/Acme/TaskBundle/Controller/DefaultController.php
// add this new use statement at the top of the class
use Acme\TaskBundle\Form\Type\TaskType;
public function newAction()
{
//$task = // ... ???
$form = $this->createForm(new TaskType(), $task);
// ...
}
...我收到以下错误:
注意:未定义变量:任务
我了解 $task 尚未正确定义。谁能向我解释我应该如何定义它?我尝试将它创建为实体、formType、未定义变量,但都没有运气。
干杯
【问题讨论】:
标签: php forms class symfony formbuilder