/** * Test finding a field that's inside a tabset, within another tab. */ function testNestedTabsFindingFieldByName() { $fields = new FieldSet(); /* 2 tabs get created within a TabSet inside our set */ $tab = new TabSet('Root', new TabSet('Content', $mainTab = new Tab('Main'), $otherTab = new Tab('Others'))); $fields->push($tab); /* Some fields get added to the 2 tabs we just created */ $fields->addFieldToTab('Root.Content.Main', new TextField('Country')); $fields->addFieldToTab('Root.Content.Others', new TextField('Email')); /* The fields we just added actually exists in the set */ $this->assertNotNull($fields->dataFieldByName('Country')); $this->assertNotNull($fields->dataFieldByName('Email')); /* The fields we just added actually exist in the tabs */ $this->assertNotNull($mainTab->fieldByName('Country')); $this->assertNotNull($otherTab->fieldByName('Email')); /* We have 1 field for each of the tabs */ $this->assertEquals(1, $mainTab->Fields()->Count()); $this->assertEquals(1, $otherTab->Fields()->Count()); $this->assertNotNull($fields->fieldByName('Root.Content')); $this->assertNotNull($fields->fieldByName('Root.Content.Main')); }
/** * @inheritdoc */ public function fieldByName($name) { return $this->tab->fieldByName(); }