symfony - Twig javascript path with id -
i use peace of code.
<a href="{{ path('person_edit', {'id': 0}) }}' + document.getelementbyid('person_search').value;"> goto item </a>
which generate correct url route /edit/{id}
, when can change routes {id}/edit
have rewrite code.(not effective.)
is possibility use document.getelementbyid('person_search').value
inside 'id'.
e.g. (doesn't work):
<a href="{{ path('person_edit', {'id': 'document.getelementbyid('person_search').value'}) }}"> goto item </a>
thank in advance.
no not possible twig code gets interpreted , executed serverside e.g way before javascript in browser executes, u can definetly use query parameters :
path = '{{ path('person_edit', {'id': 0}) }}?userid='+document.getelementbyid("user_id").value;
in controller
$request = $this->getrequest(); $userid= $request->get("userid");
but way url id 0 ommit or build url javascript or use bundles job
Comments
Post a Comment