Skip to content
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

SilverStripe 4 Actions receiving incorrect gridFieldRequest #191

Open
MasonD opened this issue Feb 22, 2019 · 0 comments
Open

SilverStripe 4 Actions receiving incorrect gridFieldRequest #191

MasonD opened this issue Feb 22, 2019 · 0 comments

Comments

@MasonD
Copy link

MasonD commented Feb 22, 2019

In the SilverStripe 4 branch, Actions receive their gridFieldRequest via Injector by asking for

private static $dependencies = [
    'GridFieldRequest' => '%$' . GridFieldDetailForm_ItemRequest::class . '.betterbuttons',
];

However, Injector injects dependencies via the singleton model, and thus caches the result of ItemRequestFactory::create. This means that if you have navigated multiple GridFields deep, every action still receives the GridFieldDetailForm_ItemRequest of the very top GridField.

The actions of every GridField nested underneath another gridfield thus all get the incorrect links, which can be seen by clicking the next or back button, which directs you all the way back to viewing the items of the top level GridField.

There doesn't seem to be any way to tell Injector to inject dependencies without caching as far as I can see. A different approach will probably have to be taken.

I'm not sure if it's the correct solution, but the timing works out such that placing
$this->gridFieldRequest = BetterButtons::getGridFieldRequest(); in Action::__construct results in every action receiving the correct ItemRequest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant