Skip to content

Commit

Permalink
Merge pull request #62 from muskie9/enhancement/customTabTitle
Browse files Browse the repository at this point in the history
ENHANCEMENT allow setting tab name via config
  • Loading branch information
muskie9 authored Aug 26, 2016
2 parents 6a0974d + cce8e1f commit 804d06e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion code/FlexSlider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
20 changes: 20 additions & 0 deletions tests/FlexSliderDataExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 804d06e

Please sign in to comment.