-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AppendFormField loses parent admins. #7185
Comments
I reopen this because it's not totally solved. It works fine for the first element of a CollectionType. Indeed, the Request is: But, the adminFetcher is setting the new Request to the admin. So I am loosing all the previous request attributes, in particular the I find a "solution", using another query param to keep the value of
But I don't think it's the best solution. Any idea @franmomu how I could solve this ? |
It's normal to not have them, IIRC [
'id' => 1,
'childId' => 2,
] in case of Back to the issue, do you have a small example or if you could create one, I don't see why it works for the first one and not the the others. |
Yes, it's the case as showed in the first screenshot.
Yes, I agree, but then I have the following issue.
I don't have a small example, but I will end creating one if I can't be clear. The script has the following code
When loading the page, the Admin has the request from the url
When you click on the Then, in the AppendFormFieldAction, the admin fetcher will look for the admin.
But the request set is the new request, the one sent to the
So then we're regenerating the oneToMany with Js, and recreating a new add button, the value
use the new request set, with no route params. I wonder if I should |
Tried, it doesn't work. What I would like is to keep the value of the initial request, even after the call ajax... |
I thought the "add button" was always the same, so every time you add an item, everything gets regenerated? |
Yes I found a solution, with
This way query params are not lost, I'll make a PR |
When using a childAdmin, with an url like:
And the following
configureNewInstance
:The
Foo
entity is automatically set to the new Bar entity.Inside the BarAdmin, I use a CollectionType with an entity Baz.
In the BazAdmin, I would expect that the Foo entity, accessible by,
would have the
Foo
entity freshly set. But currently it's not set.This is because the
AppendFormFieldElementAction
is creating the admin this way:https://github.com/sonata-project/SonataAdminBundle/blob/3.x/src/Action/AppendFormFieldElementAction.php#L54-L59
Here:
$admin
is a BarAdmin, but the parent adminFooAdmin
(with the subject id 1) is not set.Then, since we're inside a creating
https://github.com/sonata-project/SonataAdminBundle/blob/3.x/src/Action/AppendFormFieldElementAction.php#L66-L73
The else part is creating a newInstance, and the Foo entity won't be set.
The childAdmin with the ids should be sended to the request.
And the
getInstance
should create the admin with the parentAdmin set.The text was updated successfully, but these errors were encountered: