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


PHP FieldList::changeFieldOrder方法代码示例

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


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

示例1: getFormFields

 /**
  * @return FieldList Fields for this form.
  */
 protected function getFormFields()
 {
     $request = Controller::curr()->getRequest();
     $fields = new FieldList();
     if (self::config()->get('category')) {
         $categories = $this->getBlog()->Categories()->map()->toArray();
         /** @var DropDownField $categoryField */
         $categoryField = DropdownField::create('Category', _t('BlogSearchForm.Category', 'Category'), $categories, $request->getVar('category'));
         $categoryField->setHasEmptyDefault(true);
         $fields->push($categoryField);
     }
     if (self::config()->get('keyword')) {
         $keywordField = TextField::create('Keyword', _t('BlogSearchForm.Keyword', 'Keyword'), $request->getVar('keyword'));
         $fields->push($keywordField);
     }
     $fields->changeFieldOrder(self::config()->get('field_order'));
     $this->extend('updateFormFields', $fields);
     return $fields;
 }
开发者ID:webfox,项目名称:silverstripe-blog-search,代码行数:22,代码来源:BlogSearchForm.php

示例2: testChangeFieldOrder

 /**
  * FieldList::changeFieldOrder() should place specified fields in given
  * order then add any unspecified remainders at the end. Can be given an
  * array or list of arguments.
  */
 public function testChangeFieldOrder()
 {
     $fieldNames = array('A', 'B', 'C', 'D', 'E');
     $setArray = new FieldList();
     $setArgs = new FieldList();
     foreach ($fieldNames as $fN) {
         $setArray->push(new TextField($fN));
         $setArgs->push(new TextField($fN));
     }
     $setArray->changeFieldOrder(array('D', 'B', 'E'));
     $this->assertEquals(0, $setArray->fieldPosition('D'));
     $this->assertEquals(1, $setArray->fieldPosition('B'));
     $this->assertEquals(2, $setArray->fieldPosition('E'));
     $this->assertEquals(3, $setArray->fieldPosition('A'));
     $this->assertEquals(4, $setArray->fieldPosition('C'));
     $setArgs->changeFieldOrder('D', 'B', 'E');
     $this->assertEquals(0, $setArgs->fieldPosition('D'));
     $this->assertEquals(1, $setArgs->fieldPosition('B'));
     $this->assertEquals(2, $setArgs->fieldPosition('E'));
     $this->assertEquals(3, $setArgs->fieldPosition('A'));
     $this->assertEquals(4, $setArgs->fieldPosition('C'));
     unset($setArray, $setArgs);
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:28,代码来源:FieldListTest.php


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