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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -