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


PHP ReadonlyField::isReadOnly方法代码示例

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


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

示例1: getFields

 /**
  * Gets the field list for a record.
  *
  * @param GridField $grid
  * @param DataObjectInterface $record
  * @return FieldList
  */
 public function getFields(GridField $grid, DataObjectInterface $record)
 {
     $cols = $this->getDisplayFields($grid);
     $fields = new FieldList();
     $list = $grid->getList();
     $class = $list ? $list->dataClass() : null;
     foreach ($cols as $col => $info) {
         $field = null;
         if ($info instanceof Closure) {
             $field = call_user_func($info, $record, $col, $grid);
         } elseif (is_array($info)) {
             if (isset($info['callback'])) {
                 $field = call_user_func($info['callback'], $record, $col, $grid);
             } elseif (isset($info['field'])) {
                 if ($info['field'] == 'LiteralField') {
                     $field = new $info['field']($col, null);
                 } else {
                     $field = new $info['field']($col);
                 }
             }
             if (!$field instanceof FormField) {
                 throw new Exception(sprintf('The field for column "%s" is not a valid form field', $col));
             }
         }
         if (!$field && $list instanceof ManyManyList) {
             $extra = $list->getExtraFields();
             if ($extra && array_key_exists($col, $extra)) {
                 $field = Object::create_from_string($extra[$col], $col)->scaffoldFormField();
             }
         }
         if (!$field) {
             if (!$this->displayFields) {
                 // If setDisplayFields() not used, utilize $summary_fields
                 // in a way similar to base class
                 //
                 // Allows use of 'MyBool.Nice' and 'MyHTML.NoHTML' so that
                 // GridFields not using inline editing still look good or
                 // revert to looking good in cases where the field isn't
                 // available or is readonly
                 //
                 $colRelation = explode('.', $col);
                 if ($class && ($obj = singleton($class)->dbObject($colRelation[0]))) {
                     $field = $obj->scaffoldFormField();
                 } else {
                     $field = new ReadonlyField($colRelation[0]);
                 }
             } else {
                 if ($class && ($obj = singleton($class)->dbObject($col))) {
                     $field = $obj->scaffoldFormField();
                 } else {
                     $field = new ReadonlyField($col);
                 }
             }
         }
         if (!$field instanceof FormField) {
             throw new Exception(sprintf('Invalid form field instance for column "%s"', $col));
         }
         // Add CSS class for interactive fields
         if (!($field->isReadOnly() || $field instanceof LiteralField)) {
             $field->addExtraClass('editable-column-field');
         }
         $fields->push($field);
     }
     return $fields;
 }
开发者ID:ajshort,项目名称:silverstripe-gridfieldextensions,代码行数:72,代码来源:GridFieldEditableColumns.php


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