1. If DataObjectDecorator::extraFields() return an numeric array for its summary field, it need to convert to associative array like what DataObject did.
2. Not all DataObject has a 'Title' database field, but all DataObject has a 'Title' field due to function DataObject::getTitle() exists.


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@70725 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Normann Lou 2009-01-26 04:01:03 +00:00 committed by Sam Minnee
parent 5df67f78d3
commit dec5108f16
2 changed files with 7 additions and 1 deletions

View File

@ -2712,7 +2712,7 @@ class DataObject extends ViewableData implements DataObjectInterface,i18nEntityP
$fields = array();
// try to scaffold a couple of usual suspects
if ($this->hasField('Name')) $fields['Name'] = 'Name';
if ($this->hasField('Title')) $fields['Title'] = 'Title';
if ($this->hasDataBaseField('Title')) $fields['Title'] = 'Title';
if ($this->hasField('Description')) $fields['Description'] = 'Description';
if ($this->hasField('FirstName')) $fields['FirstName'] = 'First Name';
}

View File

@ -181,6 +181,12 @@ abstract class DataObjectDecorator extends Extension {
$extra_fields = $this->extraStatics();
if(isset($extra_fields['summary_fields'])){
$summary_fields = $extra_fields['summary_fields'];
// if summary_fields were passed in numeric array,
// convert to an associative array
if($summary_fields && array_key_exists(0, $summary_fields)) {
$summary_fields = array_combine(array_values($summary_fields), array_values($summary_fields));
}
if($summary_fields) $fields = array_merge($fields, $summary_fields);
}
}