本文整理汇总了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;
}