Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ENHANCEMENT Allow Controllers to opt-out or modify the back link beha…

…viour in GridFieldDetailForm
  • Loading branch information...
commit a2dbd69f2cabc009d9fd38a6237d6daf67ca02bc 1 parent 2212363
@chillu chillu authored
View
4 forms/gridfield/GridFieldDetailForm.php
@@ -231,7 +231,7 @@ function edit($request) {
$form = $this->ItemEditForm($this->gridField, $request);
$return = $this->customise(array(
- 'Backlink' => $controller->Link(),
+ 'Backlink' => $controller->hasMethod('Backlink') ? $controller->Backlink() : $controller->Link(),
'ItemEditForm' => $form,
))->renderWith($this->template);
@@ -308,7 +308,7 @@ function ItemEditForm() {
// which requires more URL knowledge than the current link to this field gives us.
// The current root record is held in session only,
// e.g. page/edit/show/6/ vs. page/edit/EditForm/field/MyGridField/....
- $form->Backlink = $toplevelController->Link();
+ $form->Backlink = $toplevelController->hasMethod('Backlink') ? $toplevelController->Backlink() : $toplevelController->Link();
}
$cb = $this->component->getItemEditFormCallback();
View
4 templates/Includes/GridFieldItemEditView.ss
@@ -1,3 +1,5 @@
-<a href="$Backlink"><% _t('Go back', 'Go back' ) %></a>
+<% if Backlink %>
+ <a href="$Backlink"><% _t('Go back', 'Go back' ) %></a>
+<% end_if %>
$ItemEditForm
Please sign in to comment.
Something went wrong with that request. Please try again.