-
Notifications
You must be signed in to change notification settings - Fork 819
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
API Add $action parameter to Controller::Link #5854
API Add $action parameter to Controller::Link #5854
Conversation
d192511
to
3e82492
Compare
There seems to be a regression in GridField... looking into it now. |
public function Link() { | ||
return get_class($this) .'/'; | ||
public function Link($action = null) { | ||
return Controller::join_links(get_class($this), $action, '/'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Why not just call with get_class +
func_get_args
- $action isn't guaranteed to be an action, it'll just be whatever the caller wants - Does it need to finish with a '/'? And if so, can't join_links do that, instead of added it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- We don't want all args, just the one. See tests below; I'm relying on $action being ignored if empty.
- Modifying join_links could have a larger range of unexpected consequences, so I've opted for the least disruptive change.
3e82492
to
f088efc
Compare
I've removed the change in behaviour to Form::FormAction() to reduce regressions. This change will now standardise the behaviour of Controller::link(), but will not increase reliance on this standard behaviour. There were too many regressions in GridField due to the original rewrite. |
We need a CMS fix too |
CMS fix at silverstripe/silverstripe-cms#1570 @dhensby , thanks! |
f088efc
to
9188628
Compare
Restarting tests. |
Reverts 1ccdcba
This is necessary to fix some actions in gridfield, where the form Link() action isn't being correctly concatenated to the parent controller.
Prior to this fix, clicking the gridfield header would cause a HTTP error (HTTP request was to
/admin/reports/EditForm/field/Reports
, instead of/admin/reports/index/EditForm/field/Reports
)The problem is that some controllers need to know if they are being appended to nested controllers, and occasionally need to add the full urlsegment in those cases. The 'home' page and the reports 'index' actions are two examples.