Skip to content
This repository
Browse code

BUG Reload full view in admin/settings to avoid tabs breaking

Had the pjax "CurrentForm" marker set to the <form> tag,
which makes sense, but excludes the tabs. On refresh,
the tabset wasn't reinitialized, showing all form elements on
one page. Its easier to simply refresh the whole content area.
  • Loading branch information...
commit b74178e7fd2a0ba2b08cd11b41f0085b1dd4eee6 1 parent 54fd54a
Ingo Schommer authored July 13, 2012
14  code/controllers/CMSSettingsController.php
@@ -5,6 +5,15 @@ class CMSSettingsController extends LeftAndMain {
5 5
 	static $url_rule = '/$Action/$ID/$OtherID';
6 6
 	static $menu_priority = -1;
7 7
 	static $menu_title = 'Settings';
  8
+
  9
+	public function getResponseNegotiator() {
  10
+		$neg = parent::getResponseNegotiator();
  11
+		$controller = $this;
  12
+		$neg->setCallback('CurrentForm', function() use(&$controller) {
  13
+			return $controller->renderWith($controller->getTemplatesWithSuffix('_Content'));
  14
+		});
  15
+		return $neg;
  16
+	}
8 17
 	
9 18
 		/**
10 19
 	 * @return Form
@@ -16,8 +25,8 @@ function getEditForm($id = null, $fields = null) {
16 25
 		$actions = $siteConfig->getCMSActions();
17 26
 		$form = new Form($this, 'EditForm', $fields, $actions);
18 27
 		$form->addExtraClass('root-form');
19  
-
20 28
 		$form->addExtraClass('cms-edit-form cms-panel-padded center');
  29
+		// don't add data-pjax-fragment=CurrentForm, its added in the content template instead
21 30
 
22 31
 		if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
23 32
 		$form->setHTMLID('Form_EditForm');
@@ -47,8 +56,7 @@ function save_siteconfig($data, $form) {
47 56
 		$siteConfig->write();
48 57
 		
49 58
 		$this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP', 'Saved.')));
50  
-	
51  
-		return $form->forTemplate();
  59
+		return $this->getResponseNegotiator()->respond($this->request);
52 60
 	}
53 61
 	
54 62
 	function LinkPreview() {
2  templates/Includes/CMSSettingsController_Content.ss
... ...
@@ -1,4 +1,4 @@
1  
-<div class="cms-content center cms-tabset $BaseCSSClasses" data-layout-type="border" data-pjax-fragment="Content">
  1
+<div class="cms-content center cms-tabset $BaseCSSClasses" data-layout-type="border" data-pjax-fragment="Content CurrentForm">
2 2
 
3 3
 	<div class="cms-content-header north">
4 4
 		<% with EditForm %>

0 notes on commit b74178e

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