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...
1 parent 54fd54a commit b74178e7fd2a0ba2b08cd11b41f0085b1dd4eee6 @chillu chillu committed Jul 13, 2012
Showing with 12 additions and 4 deletions.
  1. +11 −3 code/controllers/CMSSettingsController.php
  2. +1 −1 templates/Includes/
@@ -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('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');
@@ -47,8 +56,7 @@ function save_siteconfig($data, $form) {
$this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP', 'Saved.')));
- return $form->forTemplate();
+ return $this->getResponseNegotiator()->respond($this->request);
function LinkPreview() {
@@ -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 %>

4 comments on commit b74178e


@chillu Can you recall how to reproduce the bug that this commit was supposed to fix? The reason why I ask is because this diverges from the pjax convention of only reloading the form on error, which then completely prevents proper form validation if someone (like myself) intended to add that to the SiteConfig (in my case via DataExtension). See this bug that I think this commit created: #556

chillu commented on b74178e Jul 18, 2015

@patricknelson Hmm, three years ago ;) It'd have been something around switching from one area to another, either from a ModelAdmin, admin/pages overview, or (most likely) and admin/pages/edit/show/<id> detail view. Shouldn't serverside form validation render both for full page and PJAX reloads thougH? Happy to review a pull request.


Here you go! :D #1238


I asked since I was trying to carefully investigate the basis here so I didn't break anything. Hopefully I didnt.

Please sign in to comment.