From b74178e7fd2a0ba2b08cd11b41f0085b1dd4eee6 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 13 Jul 2012 11:00:21 +0200 Subject: [PATCH] BUG Reload full view in admin/settings to avoid tabs breaking Had the pjax "CurrentForm" marker set to the
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. --- code/controllers/CMSSettingsController.php | 14 +++++++++++--- .../Includes/CMSSettingsController_Content.ss | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/code/controllers/CMSSettingsController.php b/code/controllers/CMSSettingsController.php index b24547c7..29bd75c9 100644 --- a/code/controllers/CMSSettingsController.php +++ b/code/controllers/CMSSettingsController.php @@ -5,6 +5,15 @@ class CMSSettingsController extends LeftAndMain { static $url_rule = '/$Action/$ID/$OtherID'; static $menu_priority = -1; static $menu_title = 'Settings'; + + public function getResponseNegotiator() { + $neg = parent::getResponseNegotiator(); + $controller = $this; + $neg->setCallback('CurrentForm', function() use(&$controller) { + return $controller->renderWith($controller->getTemplatesWithSuffix('_Content')); + }); + return $neg; + } /** * @return Form @@ -16,8 +25,8 @@ class CMSSettingsController extends LeftAndMain { $actions = $siteConfig->getCMSActions(); $form = new Form($this, 'EditForm', $fields, $actions); $form->addExtraClass('root-form'); - $form->addExtraClass('cms-edit-form cms-panel-padded center'); + // don't add data-pjax-fragment=CurrentForm, its added in the content template instead if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet'); $form->setHTMLID('Form_EditForm'); @@ -47,8 +56,7 @@ class CMSSettingsController extends LeftAndMain { $siteConfig->write(); $this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP', 'Saved.'))); - - return $form->forTemplate(); + return $this->getResponseNegotiator()->respond($this->request); } function LinkPreview() { diff --git a/templates/Includes/CMSSettingsController_Content.ss b/templates/Includes/CMSSettingsController_Content.ss index 6561f0ec..b56ee115 100644 --- a/templates/Includes/CMSSettingsController_Content.ss +++ b/templates/Includes/CMSSettingsController_Content.ss @@ -1,4 +1,4 @@ -
+
<% with EditForm %>