ENHANCEMENT Allow Controllers to opt-out or modify the back link behaviour in GridFieldDetailForm

This commit is contained in:
Ingo Schommer 2012-05-08 10:24:14 +02:00
parent 2212363a0f
commit a2dbd69f2c
2 changed files with 5 additions and 3 deletions

View File

@ -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();

View File

@ -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