Disable symfony 2 csrf token protection on ajax submit

后端 未结 5 415
遇见更好的自我
遇见更好的自我 2020-12-08 13:07

i\'m building a mobile app talking to my symfony2 app via webservices I can\'t find a way to disable csrf protection on a specific controller/action

i want to post r

5条回答
  •  攒了一身酷
    2020-12-08 13:50

    Using the form factory

    For those who want to create a simple form in a controller:

    $form = $this->container->get('form.factory')
        ->createNamedBuilder(null, 'form', null, array('csrf_protection' => false))
        ->add('yourField','text', array(
            'label' => false,
            'mapped' => false
        ))
        ->getForm();
    

提交回复
热议问题