I try to submit my form by get method, but then in controller I cant get value, here is controller:
var_dump($request->query->get('startPoint')); // its NULL
My form:
<form id="s_f" action ="{{ path('trip_search') }}" method="get" novalidate="">
{{ form_widget(search_form, {'attr': {'class': 'search_form'} }) }}
</form>
Generated url:
http://example.com/app_dev.php/search_trips?search_form%5BstartPoint%5D=3123123&search_form%5BendPoint%5D=&search_form%5
Maybe problem related with this symbols %5D
in the URL ? Can somebody help me?
Do like this, if you can't find QS values:
var_dump($request->query->all());
it shows all QS values;
In your case, you can access your QS data by:
$formData = $request->query->get('search_form');
or
$formData = $request->query->get($form->getName());
it returns array of values, after that you can access startPoints
like this:
$formData['startPoints']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With