mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Simplify code to use dataFields()
This commit is contained in:
parent
2fafff084f
commit
8537d6ddb1
@ -473,17 +473,20 @@ class CMSPageHistoryController extends CMSMain
|
|||||||
return $crumbs;
|
return $crumbs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace all data fields with HTML readonly fields to display diff
|
||||||
|
*
|
||||||
|
* @param FieldList $fields
|
||||||
|
* @return FieldList
|
||||||
|
*/
|
||||||
public function transformReadonly(FieldList $fields)
|
public function transformReadonly(FieldList $fields)
|
||||||
{
|
{
|
||||||
foreach($fields as &$field) {
|
foreach ($fields->dataFields() as $field) {
|
||||||
if ($field instanceof CompositeField) {
|
if ($field instanceof HiddenField) {
|
||||||
$subfields = $this->transformReadonly($field->FieldList());
|
continue;
|
||||||
$field->setChildren($subfields);
|
|
||||||
}
|
|
||||||
if ($field->hasData() && !$field instanceof HiddenField) {
|
|
||||||
$newField = $field->castedCopy(HTMLReadonlyField::class);
|
|
||||||
$fields->replaceField($field->getName(), $newField);
|
|
||||||
}
|
}
|
||||||
|
$newField = $field->castedCopy(HTMLReadonlyField::class);
|
||||||
|
$fields->replaceField($field->getName(), $newField);
|
||||||
}
|
}
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user