php - Symfony / Sonata Admin: List form on Edit form -
i have 1 (category) many (product) relationship set up, , i'd have list of products show @ bottom of edit category page.
it seems common thing do, haven't found way (or examples of it). have managed product display using sonata_type_collection gives me whole edit form product, when want list of products associated category.
two questions here, really:
is possible?
is discouraged (which explain lack of examples)? if so, why?
the fastest way looking overriding edit template. @ admin serivce declaration can so:
services: sonata.admin.mail: class: %sonata.admin.category.class% tags: - { name: sonata.admin, manager_type: orm, group: "categories", label: "category" } arguments: - ~ - %skooli.category.class% - ~ calls: - [ settemplate, ["edit", "acmeadminbundle:categoryadmin:edit.html.twig"] ]
then, under acmebundle/resources/views/categoryadmin/edit.html.twig
can have this:
{% extends 'sonataadminbundle:crud:base_edit.html.twig' %} {# override block parent view if necessary #} {% block products %} <ul> {% product in object.products%} <li>{{ product.name }}</li> {% endfor %} </ul> {% endblock products %}
Comments
Post a Comment