0

I have this code in my Twig template:

{% for entity in entities %}
<ul>
    <li>{{ entity.getName }} | <a href="{{ path('detail_group_edit', { 'detail_group_id': entity.getId }) }}">Editar</a> - <a href="{{ path('detail_group_delete', { 'detail_group_id': entity.getId }) }}">Eliminar</a>
            {{ render(controller('ProductBundle:DetailGroup:index', { 'parent_id': entity.getId })) }}
        </li>
    </ul>
{% endfor %}

<dl class="sub-nav">
    <dd><a href="#" id="detail_group_create">Add new</a></dd>
</dl>

<script>
    $(function() {
        $("#detail_group_create").click(function() {
            loadCenterLayout(Routing.generate('detail_group_new'));
        });
    });
</script>

Because I'm calling this {{ render(controller('ProductBundle:DetailGroup:index', { 'parent_id': entity.getId })) }} I get the Add new link twice. I don't want to create a new function to handle the same, how did yours deal with this? Any tips or advice?

Reynier
  • 2,420
  • 11
  • 51
  • 91

1 Answers1

1

If I understood you correctly, you want to have index with dynamic center part of the layout. You either have to have:

  • separate controller functions or
  • single controller function but some GET/POST parameter and big IF/ELSE branching.

In second case you must not rely on @Template annotation (in case you use them) but rather on manually calling appropriate template render based on which branch you're in.

Did I get your issue right?

Jovan Perovic
  • 19,846
  • 5
  • 44
  • 85