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 similar that we can do with symfony2.
I have seen some examples but none is working for me. Suppose I have a form field with the name username. In the form action I tried to use something like this:
$request = $this->getRequest();
$username= $request->request->get('username');
I have also tried
$username = $request->getParameter('username');
and
$username=$request->request->getParameter('username');
But none of the options is working.However following worked fine:
foreach($request->request->all() as $req){
print_r($req['username']);
}
Where am I doing wrong in using getParameter()
method. Any help will be appreciated.
$request->request-get()
should be$request->request->get()
. Could that be it? – halferget()
is the correct method and (b) turned on PHP notices so you can see if there are any problems? (c) Does Symfony 2 have a debug toolbar like symfony 1, so you can see if you've made any errors? – halfer