Skip to content

Instantly share code, notes, and snippets.

@redleafar
Last active October 31, 2016 14:39
Show Gist options
  • Save redleafar/804e508523cb65f7c3ec2c7b6bc575a9 to your computer and use it in GitHub Desktop.
Save redleafar/804e508523cb65f7c3ec2c7b6bc575a9 to your computer and use it in GitHub Desktop.
Get parameters of a get request in a controller

If is just a parameter use:

$page = $request->query->get('page');

If you have to get a form value do this (pais is a field of the form):

$data = $formtest->getData();
$pais = $data->getPais();

I did somehting like this once:

$words = $request->query->get('formname')['searchword'];

But is not the best way, because you have to look what is the name of the form generated by twig...

Remember:

$request->query… //for get
$request->request//for post
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment