I am returning this error when I try to give the href into a twig file ---
Unexpected token "punctuation" of value "(" ("end of print statement" expected) in myBundle:Settings:settings.html.twig at line 53
Twig :
{% for usr in userStats %}
{<td>
<a href="{{ '/settings/management/aptid/{id}' ('myBundle_apt',{ aptId: usr.publisherId }) }}" class="btn btn-default btn-xs myOnbutton">ON</a>
</td>}
Controller
/**
* @Route("/settings/management/aptid/{id}", name="myBundle_apt")
* @ParamConverter("apt", class="myBundle:UserStats")
*/
public function publishiddAction($id) {
if (null !== ($request->get('myOnbutton'))) {
$statss = $this->getDoctrine()
->getRepository('myBundle:UserStats')
->findBy(array('aptId' => $id));
}
return $statss;
return new Response("");
}
Does anyone know how to solve this problem?
Your Twig is incorrect, you don't need {
I think you need to look at the documentation of twig
{% for usr in userStats %}
{<td>
<a href="{{ '/settings/management/aptid/{id}' ('myBundle_apt',{ aptId: usr.publisherId }) }}" class="btn btn-default btn-xs myOnbutton">ON</a>
</td>}
{% for usr in userStats %}
<td>
<a href="{{ path('myBundle_apt', { 'aptId': usr.publisherId }) }}"
class="btn btn-default btn-xs myOnbutton">ON</a>
</td>
{% endfor %}