Symfony get form data in controller

前端 未结 2 2044
眼角桃花
眼角桃花 2021-01-17 22:01

I have this view:

//login.html.twig





    

        
2条回答
  •  北海茫月
    2021-01-17 22:20

    You should pass the Request object to the action method then deal with it:

    public function conectionAction(Request $request){
        if ($request->getMethod() == Request::METHOD_POST){
            $user = $request->request->get('user');
            $password = $request->request->get('password');
        }
    }
    

    However I suggest you to use the Symfony Form Component to dial with this situation.

提交回复
热议问题