当前位置: 首页>>代码示例>>PHP>>正文


PHP FieldGroup::fieldByName方法代码示例

本文整理汇总了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());
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:22,代码来源:FieldListTest.php


注:本文中的FieldGroup::fieldByName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。