<?php
namespace Acme\TaskBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Acme\TaskBundle\Entity\Task;
use Symfony\Component\HttpFoundation\Request;
class DefaultController extends Controller
{
public function indexAction($name)
{
return $this->render('AcmeTaskBundle:Default:index.html.twig', array('name' => $name));
}
public function newAction(Request $request)
{
// just setup a fresh $task object (remove the dummy data)
$task = new Task();
$task->setTask('Write a blog post');
$task->setDueDate(new \DateTime('tomorrow'));
$form = $this->createFormBuilder($task)
->add('task', 'text')
->add('dueDate', 'date')
->getForm();
if ($request->isMethod('POST'))
{
$form->bind($request);
if ($form->isValid())
{
// perform some action, such as saving the task to the database
return $this->redirect($this->generateUrl('task_success'));
}
}
}
}
它在这里说:控制器必须返回一个响应(给定空值)。您是否忘记在控制器的某处添加 return 语句?谁可以帮我这个事