Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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 chillu authored
14 code/controllers/CMSSettingsController.php
View
@@ -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 @@ function getEditForm($id = null, $fields = null) {
$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 @@ function save_siteconfig($data, $form) {
$siteConfig->write();
$this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP', 'Saved.')));
-
- return $form->forTemplate();
+ return $this->getResponseNegotiator()->respond($this->request);
}
function LinkPreview() {
2  templates/Includes/CMSSettingsController_Content.ss
View
@@ -1,4 +1,4 @@
-<div class="cms-content center cms-tabset $BaseCSSClasses" data-layout-type="border" data-pjax-fragment="Content">
+<div class="cms-content center cms-tabset $BaseCSSClasses" data-layout-type="border" data-pjax-fragment="Content CurrentForm">
<div class="cms-content-header north">
<% with EditForm %>
Please sign in to comment.
Something went wrong with that request. Please try again.