Receiving a POST request on Symfony2

I searched for this and any of the answers work for me:

I use this to get a POST request:

 $request = Request::createFromGlobals(); $order = $request->query->get('Ds_Order'); 

But order never matters, although the name is correct. If I execute a GET request, this value exists.

This is the var_dump of the request $ request

 object(Symfony\Component\HttpFoundation\Request)#841 (18) { ["attributes"]=> object(Symfony\Component\HttpFoundation\ParameterBag)#838 (1) { ["parameters":protected]=> array(0) { } } ["request"]=> object(Symfony\Component\HttpFoundation\ParameterBag)#840 (1) { ["parameters":protected]=> array(15) { ["Ds_Date"]=> string(10) "10/10/2012" ["Ds_Hour"]=> string(5) "14:31" ["Ds_Currency"]=> string(3) "978" ["Ds_Order"]=> string(4) "0026" } } } 

Does anyone know how to access the attributes that send me?

Thanks.

+7
source share
1 answer

To get the POST request parameter, you should use

 $order = $request->request->get('Ds_Order'); 

Read Queries and Answers in Symfony

 // retrieve GET variables $request->query->get('foo'); // retrieve POST variables $request->request->get('bar', 'default value if bar does not exist'); 
+27
source

All Articles