I am following the tutorial from Symfony2 on how to use form classes.
I am doing something wrong, because when I use the following example code:
// 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);
// ...
}
…I receive the following error:
Notice: Undefined variable: task
I understand that $task has not yet been defined properly. Can anyone explain to me how I should define it? I tried creating it as entity, as formType, as undefined variable, but all to no luck.
Cheers
If you follow the tutorial from the first then you should have created a
Taskentity inAcme\TaskBundle\Entitynamespace. So your controller would be,