Hi everyone,
I really enjoy the childAdmin feature of Sonata, but I can't figure how to use it with nested childs. Suppose we have 3 entities :
From url point, I can use : http://domain.ext/admin/dictionnary/1/page/1/edit
or : http://domain.ext/admin/page/1/word/1/edit
but I can use : http://domain.ext/admin/dictionnary/1/page/1/word/1/edit
Is there actually a way to do this (more than 2 admin levels) ?
Is there actually a way to do this (more than 2 admin levels) ?
Not sure but IIRC this is not supported :(
Can you use debug:router to see what routes you can actually use instead of trying random urls ?
No route is created by Sonata to do such thing (nothing corresponding in debug:router), that's the problem. The documentation explains how to ad a one level childAdmin. But if you add a childAdmin to this child, I does not add a route.
I don't know how to code this functionnality.
You should probably have a look at AbstractAdmin::buildRoutes, see how it behaves. Also, take care, I think it is important to clear your cache if you want it to be fired.
Creating the route is not the problem. A whole system of persisting and breadcrumbs is deployed when you use childAdmin. I'd like to keep this for nested childAdmin.
Creating the route is not the problem. A whole system of persisting and breadcrumbs is deployed when you use childAdmin. I'd like to keep this for nested childAdmin.
Well how can you know if it works if you can't route a page showing this grand-children-admin ?
For 1 level childAdmin I didn't create any route. As explained in documentation you just have to create an EntityAdmin.php and a service with a specific child. The route is then available.
I can't create a route for a service that does not exists. My question is: how can I create a service for a 2 or more levels childAdmin ?
What prevents you from doing something like this :
services:
parent.service:
…
addChild child service
child.service:
…
addChild grandchild service
grandchild.service:
…
Well, that's exactly how I thought it should work. But it doesn't. To explain it here is an exemple:
Let's say I have 3 entities:
AddChild parameters are used exactly like you said:
etablissement.service: addChild service service
service.service: addChild poste service
poste.service
(sorry for the "Service service" but that's how it has to be called in my case)
If I try to travel from an Etablissement to a Poste:
1) I open an Etablissement (called "CHRU")

2) From this edit panel, I open the Services tab, which gives me all Services from the selected Etablissement. And you can see that the breadcrumbs keep in memory the Etablissement used to access this list

3) From this list, I open a Service (called "Psychiatrie"). Inside this Service I can't access the Postes tab (the tabs displayed seem to be those from the Etablissement only)

4) If I access the same Service directly (take a look at the url, the Etablissement id is not used) it works. But it does not provide a full breadcrumb so you can't navigate up and down trought parents/children.


So I think that the main problem is that this functionnality is based on service parameters from the first entity accessed. Instead I'd like it to use parameters from the current displayed entity service.
I've had a look at the main controller, and clearly, 3-level nesting is not supported : there is a childId, but no grandChildId. Closing, then.
@greg0ire Any workaround on this?
Not that I'm aware of.
@ceesvanegmond I'm currently working on providing a PR for this feature (nested child admins). I already did it for a business project. I only need the agreement of my company to publish the feature and a little bit of time to clean the code and write a PR. Stay tuned!
@jlamur I'm glad to help out! 👍
PR open here: #4542.
Most helpful comment
@ceesvanegmond I'm currently working on providing a PR for this feature (nested child admins). I already did it for a business project. I only need the agreement of my company to publish the feature and a little bit of time to clean the code and write a PR. Stay tuned!