admin - Sonata/symfony - parent/child structure setup -
I'm asking for a while. Can not believe there is not a single god who does not know the answer and I am a little disappointed.
In Sonata, I can not work with URL structure / pattern / parent / id / children / list. Lot, rather went through bad 4.6.
Can anyone explain step-by-step to establish such a structure?
I will use the example given in my explanation, a basic post / comment relationship.
The parent / child link (one team / multiple lessons link) between your organizations (parent) and comment (child).
You must add to the service announcement that adds the addadd group that targets the child's admin service:
services.yml
Sonata.news.admin.comment: Class: sonata \ newsbundle \ admin \ adminAdmin logic: [~, sonata \ newsbundle \ model \ remark, sonata news bundle: comment admin] Tags: - {name: sonata.admin, manager_type: orm, Group: "content"} sonata.news.admin.post: class: Sonata \ NewsBundle \ Admin \ PostAdmin logic: [~, sonata \ newsbundle \ model \ post, sonata news bundle: post Min] Tags: - {name: sonata.admin, manager_type: orm, group: "content"} call: - [addChild, ['sonata.news.admin.comment']]
Comment in your Admin Class, you need to add propertiesAccident Mapping to parents to filter this child.
Comment Administrator
Expands class CommentAdmin Administrator {Protected $ parentAssociationMapping = 'post'; ...}
Then you will have a new route available: / parent / ID / child / list, you can use the console to find your new root identifier (Php app) / console router: debug). If you want an easy way to use it in the admin, then I suggest adding a button directly to the parent admin list to access your child's comments:
Create a template that Add a button to access the child Comment:
post_comments.html.twig
& lt; One class = "btn btn-sm btn-default" href = "{{path ('OUR_NEW_CHILD_ROUTE_ID', {'id': object.id})}}" & gt; Comments & lt; / A & gt;
Then add button action in the parent admin in this case. PostAdmin:
PostAdmin
Extension of class post admin administrator (protected work) structure ('show' => array), 'edit' = & gt; Array ()), 'annotations' = & gt; Array ('Template' = & gt; 'PATH_TWIG'))))}}
Hope you set up the parent / child administrator
Comments
Post a Comment