symfony 形式的处理请求的作用是什么

Mar*_*web 0 symfony

我正在使用 FormBuilderInterface 来创建我的表单,所以我发现我可以使用函数 isvalid() 验证我的表单,我有一个 handleRequest($request) 问题,我不明白它的作用是什么。这是我的代码:

function ajout2Action()
{
    $client= new \Esprit\PiBundle\Entity\Client();
    $formv= new \Esprit\PiBundle\Form\ClientType();
    $form=  $this->createForm($formv,$client);
     $request = $this->get('request');
  if($form->handleRequest($request)->isValid())
    {
         $em=$this->getDoctrine()->getManager();
         $em->persist($client);
         $em->flush();


}
Run Code Online (Sandbox Code Playgroud)

感谢您的帮助 。

Dhe*_*raj 5

直接来自用于处理表单数据的文档

它从前一个请求中获取 POST 数据,处理它,并运行任何验证(检查预期数据与接收数据的完整性)。它仅对 POST 请求执行此操作

阅读更多