Browse files

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

…viour in GridFieldDetailForm
  • Loading branch information...
1 parent 2212363 commit a2dbd69f2cabc009d9fd38a6237d6daf67ca02bc @chillu chillu committed May 8, 2012
Showing with 5 additions and 3 deletions.
  1. +2 −2 forms/gridfield/GridFieldDetailForm.php
  2. +3 −1 templates/Includes/GridFieldItemEditView.ss
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

0 comments on commit a2dbd69

Please sign in to comment.