From a2dbd69f2cabc009d9fd38a6237d6daf67ca02bc Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 8 May 2012 10:24:14 +0200 Subject: [PATCH] ENHANCEMENT Allow Controllers to opt-out or modify the back link behaviour in GridFieldDetailForm --- forms/gridfield/GridFieldDetailForm.php | 4 ++-- templates/Includes/GridFieldItemEditView.ss | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/forms/gridfield/GridFieldDetailForm.php b/forms/gridfield/GridFieldDetailForm.php index bc369107f..141a14942 100755 --- a/forms/gridfield/GridFieldDetailForm.php +++ b/forms/gridfield/GridFieldDetailForm.php @@ -231,7 +231,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler { $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 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler { // 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(); diff --git a/templates/Includes/GridFieldItemEditView.ss b/templates/Includes/GridFieldItemEditView.ss index d924c1060..8a6a025b8 100644 --- a/templates/Includes/GridFieldItemEditView.ss +++ b/templates/Includes/GridFieldItemEditView.ss @@ -1,3 +1,5 @@ -<% _t('Go back', 'Go back' ) %> +<% if Backlink %> + <% _t('Go back', 'Go back' ) %> +<% end_if %> $ItemEditForm \ No newline at end of file