Skip to content

Commit

Permalink
Merge pull request silverstripe#912 from chillu/pulls/7980
Browse files Browse the repository at this point in the history
BUG Remove .ss-tabset class from CMS tabs to prevent rogue ajax load (#7...
  • Loading branch information
sminnee committed Oct 31, 2012
2 parents f861ff9 + bcbf463 commit 7d095a1
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 9 deletions.
4 changes: 3 additions & 1 deletion admin/code/LeftAndMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,9 @@ public function getEditForm($id = null, $fields = null) {
$form->setAttribute('data-pjax-fragment', 'CurrentForm');

// Set this if you want to split up tabs into a separate header row
// if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
// if($form->Fields()->hasTabset()) {
// $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
// }

// Add a default or custom validator.
// @todo Currently the default Validator.js implementation
Expand Down
8 changes: 6 additions & 2 deletions admin/code/SecurityAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ public function getEditForm($id = null, $fields = null) {
// necessary for tree node selection in LeftAndMain.EditForm.js
new HiddenField('ID', false, 0)
);


// Tab nav in CMS is rendered through separate template
$root->setTemplate('CMSTabSet');

// Add roles editing interface
Expand Down Expand Up @@ -161,7 +162,10 @@ public function getEditForm($id = null, $fields = null) {
);
$form->addExtraClass('cms-edit-form');
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
// Tab nav in CMS is rendered through separate template
if($form->Fields()->hasTabset()) {
$form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
}
$form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
$form->setAttribute('data-pjax-fragment', 'CurrentForm');

Expand Down
8 changes: 6 additions & 2 deletions admin/templates/CMSTabSet.ss
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<div $AttributesHTML>
<%-- Tab nav is rendered in CMSEditForm.ss --%>
<%-- Exclude ".ss-tabset" class to avoid inheriting behaviour --%>
<%-- The ".cms-tabset" class needs to be manually applied to a container elment, --%>
<%-- above the level where the tab navigation is placed. --%>
<%-- Tab navigation is rendered through various templates, --%>
<%-- e.g. through LeftAndMain_EditForm.ss. --%>

<div $AttributesHTML>
<% loop Tabs %>
<div $AttributesHTML>
<% if Tabs %>
Expand Down
2 changes: 1 addition & 1 deletion forms/TabSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function getAttributes() {
$this->attributes,
array(
'id' => $this->id(),
'class' => 'ss-tabset ' . $this->extraClass()
'class' => $this->extraClass()
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion forms/gridfield/GridFieldDetailForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public function ItemEditForm() {
$form->setAttribute('data-pjax-fragment', 'CurrentForm Content');
if($form->Fields()->hasTabset()) {
$form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
$form->addExtraClass('ss-tabset cms-tabset');
$form->addExtraClass('cms-tabset');
}

$form->Backlink = $this->getBackLink();
Expand Down
2 changes: 1 addition & 1 deletion templates/forms/TabSet.ss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div $AttributesHTML>
<div $getAttributesHTML("class") class="ss-tabset $extraClass">
<ul>
<% loop Tabs %>
<li class="$FirstLast $MiddleString $extraClass"><a href="#$id" id="tab-$id">$Title</a></li>
Expand Down
2 changes: 1 addition & 1 deletion tests/forms/FormFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testAttributesHTML() {
$this->assertNotContains('two="2"', $field->getAttributesHTML('one', 'two'));
$this->assertContains('three="3"', $field->getAttributesHTML('one', 'two'));
}

public function testEveryFieldTransformsReadonlyAsClone() {
$fieldClasses = ClassInfo::subclassesFor('FormField');
foreach($fieldClasses as $fieldClass) {
Expand Down

0 comments on commit 7d095a1

Please sign in to comment.