diff --git a/code/FlexSlider.php b/code/FlexSlider.php index a9df1ee..d311e30 100644 --- a/code/FlexSlider.php +++ b/code/FlexSlider.php @@ -42,7 +42,9 @@ public function updateCMSFields(FieldList $fields) $config->addComponent(new GridFieldDeleteAction(false)); $SlidesField = GridField::create('Slides', 'Slides', $this->owner->Slides()->sort('SortOrder'), $config); - $fields->addFieldsToTab('Root.Slides', array( + $slideTitle = $this->owner->stat('slide_tab_title') ? $this->owner->stat('slide_tab_title') : 'Slides'; + + $fields->addFieldsToTab("Root.{$slideTitle}", array( HeaderField::create('SliderHD', 'Slides', 3), $SlidesField, ToggleCompositeField::create('ConfigHD', 'Slider Settings', array( diff --git a/tests/FlexSliderDataExtensionTest.php b/tests/FlexSliderDataExtensionTest.php index d05dcae..57e9e25 100644 --- a/tests/FlexSliderDataExtensionTest.php +++ b/tests/FlexSliderDataExtensionTest.php @@ -2,6 +2,26 @@ class FlexSliderDataExtensionTest extends FlexSliderTest { + public function testTabNameConfig() + { + + $page = new Page(); + $page->write(); + $extension = new FlexSlider(); + $pageFields = $page->getCMSFields(); + $extension->updateCMSFields($pageFields); + $this->assertNotNull($pageFields->fieldByName('Root.Slides')); + + Config::inst()->update('Page', 'slide_tab_title', 'MyCustomSlideTitle'); + $page2 = Page::create(); + $page2->write(); + $page2Fields = $page2->getCMSFields(); + $extension->updateCMSFields($page2Fields); + $this->assertNull($page2Fields->fieldByName('Root.Slides')); + $this->assertNotNull($page2Fields->fieldByName('Root.MyCustomSlideTitle')); + + } + public function testUpdateCMSFields() { $extension = new FlexSlider();