symfony2表单绑定请求返回500错误
所以我有一个表单类型“PictureType”: 当我提交表格时,它给了我500个错误symfony2表单绑定请求返回500错误,symfony,symfony-forms,symfony-2.2,Symfony,Symfony Forms,Symfony 2.2,所以我有一个表单类型“PictureType”: 当我提交表格时,它给了我500个错误 "The controller must return a response (null given). Did you forget to add a return statement somewhere in your controller?" 有人能帮我吗:(?不要使用echo,控制器必须返回响应: $form->bindRequest($this->get('request')
"The controller must return a response (null given). Did you forget to add a return statement somewhere in your controller?"
有人能帮我吗:(?不要使用echo,控制器必须返回响应:
$form->bindRequest($this->get('request')); // this line gives the error
if( $form->isValid() )
{
return new Response('Hello world!');
}
请参阅以下链接:
use AB\MyBundle\Form\Type\PictureType;
use AB\MyBundle\Form\Model\Picture;
...
...
$form = $this->createForm(new PictureType, new Picture);
if( $this->get('request')->getMethod() == 'POST' )
{
echo "1"; // 1 is printed
$form->bindRequest($this->get('request')); // this line gives the error
echo "2"; // 2 is not printed
if( $form->isValid() )
{
}
}
return $this->render("ABMyBundle:Default:pic.html.twig",array(
'form' => $form->createview()
));
"The controller must return a response (null given). Did you forget to add a return statement somewhere in your controller?"
$form->bindRequest($this->get('request')); // this line gives the error
if( $form->isValid() )
{
return new Response('Hello world!');
}
$form = $this->createForm(new PictureType, new Picture);
if( $this->get('request')->getMethod() == 'POST' )
{
echo "1";
$form->bind($request);
if( $form->isValid() )
{
echo "2";
}
}