How to get form values in Symfony2 controller

前端 未结 13 1514
挽巷
挽巷 2020-12-12 19:17

I am using a login form on Symfony2 with the following controller code

public function loginAction(Request $request)
{
    $user = new SiteUser();
    $form          


        
13条回答
  •  孤城傲影
    2020-12-12 20:10

    In Symfony 2 ( to be more specific, the 2.3 version ) you can get a data of an field by

    $var = $form->get('yourformfieldname')->getData();
    

    or you can get all data sent

    $data = $form->getData();
    

    where '$data' is an array containing your form fields' values.

提交回复
热议问题