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


PHP FieldList::first方法代码示例

本文整理汇总了PHP中FieldList::first方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldList::first方法的具体用法?PHP FieldList::first怎么用?PHP FieldList::first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FieldList的用法示例。


在下文中一共展示了FieldList::first方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateCMSFields

 /**
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     $tabName = Config::inst()->get('Downloadable', 'tab_name');
     $tabFields = array();
     $upload = new UploadField('DownloadableFiles', '');
     $upload->setFolderName(Config::inst()->get('Downloadable', 'source_folder'));
     $tabFields[] = $upload;
     // For certain types of products, it makes sense to include downloads
     // from parent (ProductVariation) or child products (GroupedProduct)
     // NOTE: there could be better ways to do this that don't involve checking
     // for specific classes. The advantage here is that the fields show up
     // even if the product has not yet been saved or doesn't yet have a
     // parent or child products.
     $p = $this->owner instanceof ProductVariation ? $this->owner->Product() : $this->owner->Parent();
     if ($p && $p->exists() && $p->hasExtension('Downloadable')) {
         $tabFields[] = new CheckboxField('IncludeParentDownloads', 'Include downloads from parent product in purchase');
     } elseif (class_exists('GroupedProduct') && $this->owner instanceof GroupedProduct) {
         $tabFields[] = new CheckboxField('IncludeChildDownloads', 'Include downloads from child products in purchase');
     }
     // this will just add unnecessary queries slowing down the page load
     //$tabFields[] = new LiteralField('DownloadCount', '<p>Total Downloads: <strong>' . $this->owner->getDownloads()->count() . '</strong></p>');
     // Product variations don't have tabs, so we need to be able
     // to handle either case.
     if ($fields->first() instanceof TabSet) {
         $fields->addFieldsToTab("Root.{$tabName}", $tabFields);
     } else {
         $fields->push(new HeaderField('DownloadsHeader', $tabName));
         foreach ($tabFields as $f) {
             $fields->push($f);
         }
     }
 }
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-shop-downloadable,代码行数:35,代码来源:Downloadable.php

示例2: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     $fields->removeByName('LastSignificantChange');
     $fields->removeByName('ChangeDescription');
     if ($this->owner->LastSignificantChange !== NULL) {
         $dateTime = new DateTime($this->owner->LastSignificantChange);
         //Put these fields on the top of the First Tab's form
         $fields->first()->Tabs()->first()->getChildren()->unshift(LabelField::create("infoLastSignificantChange", "<strong>Last Significant change was at: " . "{$dateTime->Format('d/m/Y H:i')}</strong>"));
         $fields->insertAfter(CheckboxField::create("isSignificantChange", "CLEAR Last Significant change: {$dateTime->Format('d/m/Y H:i')}")->setDescription('Check and save this Record again to clear the Last Significant change date.')->setValue(FALSE), 'infoLastSignificantChange');
         $fields->insertAfter(TextField::create('ChangeDescription', 'Description of Changes')->setDescription('This is an automatically generated list of changes to important fields.'), 'isSignificantChange');
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-australia-datachange-tracker,代码行数:12,代码来源:SignificantChangeRecordable.php

示例3: getRawField

 /**
  * @return TextField
  */
 public function getRawField()
 {
     return $this->children->first();
 }
开发者ID:helpfulrobot,项目名称:betterbrief-silverstripe-autocompletefield,代码行数:7,代码来源:AutocompleteField.php

示例4: testReplaceField

 /**
  * Test replacing a field with another one.
  */
 public function testReplaceField()
 {
     $fields = new FieldList();
     $tab = new Tab('Root');
     $fields->push($tab);
     /* A field gets added to the set */
     $fields->addFieldToTab('Root', new TextField('Country'));
     $this->assertSame($fields->dataFieldByName('Country'), $tab->fieldByName('Country'));
     $fields->replaceField('Country', new EmailField('Email'));
     $this->assertEquals(1, $tab->Fields()->Count());
     $fields = new FieldList();
     $fields->push(new TextField('Name', 'Your name'));
     $brack = new TextField('Name[Field]', 'Your name');
     $fields->replaceField('Name', $brack);
     $this->assertEquals(1, $fields->Count());
     $this->assertEquals('Name[Field]', $fields->first()->getName());
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:20,代码来源:FieldListTest.php


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