mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Added FieldSet->hasTabSet() incl. unit test
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63628 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
7ab2748034
commit
21859d3d97
@ -198,6 +198,19 @@ class FieldSet extends DataObjectSet {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function hasTabSet() {
|
||||||
|
foreach($this->items as $i => $field) {
|
||||||
|
if(is_object($field) && $field instanceof TabSet) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the specified tab object, creating it if necessary.
|
* Returns the specified tab object, creating it if necessary.
|
||||||
*
|
*
|
||||||
|
@ -89,6 +89,18 @@ class FieldSetTest extends SapphireTest {
|
|||||||
$this->assertEquals($tab1, $fields->fieldByName('Root')->fieldByName('Tab1'));
|
$this->assertEquals($tab1, $fields->fieldByName('Root')->fieldByName('Tab1'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testHasTabSet() {
|
||||||
|
$untabbedFields = new FieldSet(
|
||||||
|
new TextField('Field1')
|
||||||
|
);
|
||||||
|
$this->assertFalse($untabbedFields->hasTabSet());
|
||||||
|
|
||||||
|
$tabbedFields = new FieldSet(new TabSet(
|
||||||
|
new Tab('Tab1')
|
||||||
|
));
|
||||||
|
$this->assertTrue($tabbedFields->hasTabSet());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test removing an array of fields from a tab in a set.
|
* Test removing an array of fields from a tab in a set.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user