How to get the request parameters in Symfony 2?

后端 未结 16 1542
Happy的楠姐
Happy的楠姐 2020-12-02 05:02

I am very new to symfony. In other languages like java and others I can use request.getParameter(\'parmeter name\') to get the value.

Is there anything

16条回答
  •  不思量自难忘°
    2020-12-02 05:40

    You can Use The following code to get your form field values

    use Symfony\Component\HttpFoundation\Request;
    
    public function updateAction(Request $request)
    {
        // retrieve GET and POST variables respectively
        $request->query->get('foo');
        $request->request->get('bar', 'default value if bar does not exist');
    }
    

    Or You can also get all the form values as array by using

    $request->request->all()
    

提交回复
热议问题