Skip to content
This repository
Browse code

FIX 7617: Back button in CMS after Add/Edit/View action in GridField …

…does not work
  • Loading branch information...
commit 78038eb75e1e41feb50dc2649a37d63c3531af4d 1 parent 155758f
jakr authored July 05, 2012 chillu committed July 13, 2012

Showing 1 changed file with 9 additions and 5 deletions. Show diff stats Hide diff stats

  1. 14  forms/gridfield/GridFieldDetailForm.php
14  forms/gridfield/GridFieldDetailForm.php
@@ -328,11 +328,15 @@ function ItemEditForm() {
328 328
 			$form->addExtraClass('cms-content cms-edit-form center ss-tabset');
329 329
 			$form->setAttribute('data-pjax-fragment', 'CurrentForm Content');
330 330
 			if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
331  
-			// TODO Link back to controller action (and edited root record) rather than index,
332  
-			// which requires more URL knowledge than the current link to this field gives us.
333  
-			// The current root record is held in session only, 
334  
-			// e.g. page/edit/show/6/ vs. page/edit/EditForm/field/MyGridField/....
335  
-			$form->Backlink = $toplevelController->hasMethod('Backlink') ? $toplevelController->Backlink() : $toplevelController->Link();
  331
+
  332
+			if($toplevelController->hasMethod('Backlink')) {
  333
+				$form->Backlink = $toplevelController->Backlink();
  334
+			} elseif($this->popupController->hasMethod('Breadcrumbs')) {
  335
+				$parents = $this->popupController->Breadcrumbs(false)->items;
  336
+				$form->Backlink = array_pop($parents)->Link;
  337
+			} else {
  338
+				$form->Backlink = $toplevelController->Link();
  339
+			}
336 340
 		}
337 341
 
338 342
 		$cb = $this->component->getItemEditFormCallback();

1 note on commit 78038eb

mattclegg

Im so glad this has been fixed

Please sign in to comment.
Something went wrong with that request. Please try again.