One of my route is defined like this:
society_mybundle_searchpage:
pattern: /search/cp/{cp}
defaults: { _controller: SocietyMyBundle:Search:searchByCP }
So it needs one parameter: {cp}
.
Now I'd like to create a form with an input widget. So my code is like that:
<form onsubmit="return search();" action="#">
{{ form_rest(form) }}
</form>
(Nothing specific, I let symfony do all the work for me). Note that this form calls a JS function: search()
. So here's my code in twig:
<script type="text/javascript">
<!--
function verif_formulaire(){
/* some code to get the value of the cp */
...
/* then: */
ss="{{ path('society_mybundle_searchpage', {'cp': '+cp+'}) }}";
return true;
}
-->
</script>
The output is:
function verif_formulaire(){
ss="/symfony/web/app_dev.php/pizzas/search/cp/+tt+";
return true;
}
This is not the output I need. I want the output to be exactly like that this:
function verif_formulaire(){
ss="/symfony/web/app_dev.php/pizzas/search/cp/"+tt+"/";
return true;
}
How shall I proceed?