本文整理汇总了PHP中FieldGroup::fieldByName方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldGroup::fieldByName方法的具体用法?PHP FieldGroup::fieldByName怎么用?PHP FieldGroup::fieldByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FieldGroup
的用法示例。
在下文中一共展示了FieldGroup::fieldByName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFieldgroup
/**
* Test that groups can be added to a fieldlist
*/
public function testFieldgroup()
{
$fields = new FieldList();
$tab = new Tab('Root');
$fields->push($tab);
$fields->addFieldsToTab('Root', array($group1 = new FieldGroup(new TextField('Name'), new EmailField('Email')), $group2 = new FieldGroup(new TextField('Company'), new TextareaField('Address'))));
/* Check that the field objects were created */
$this->assertNotNull($fields->dataFieldByName('Name'));
$this->assertNotNull($fields->dataFieldByName('Email'));
$this->assertNotNull($fields->dataFieldByName('Company'));
$this->assertNotNull($fields->dataFieldByName('Address'));
/* The field objects in the set should be the same as the ones we created */
$this->assertSame($fields->dataFieldByName('Name'), $group1->fieldByName('Name'));
$this->assertSame($fields->dataFieldByName('Email'), $group1->fieldByName('Email'));
$this->assertSame($fields->dataFieldByName('Company'), $group2->fieldByName('Company'));
$this->assertSame($fields->dataFieldByName('Address'), $group2->fieldByName('Address'));
/* We'll have 2 fields directly inside the tab */
$this->assertEquals(2, $tab->Fields()->Count());
}