APICHANGE: add updateFieldLabels() to DataObjectDecorator, so as that a dataobject could update fieldLables by its decorator.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64805 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Normann Lou 2008-10-28 03:03:16 +00:00
parent bff5942338
commit 27a868ebf2
2 changed files with 18 additions and 2 deletions

View File

@ -2541,8 +2541,10 @@ class DataObject extends ViewableData implements DataObjectInterface {
$autoLabels[$name] = FormField::name_to_label($name);
}
}
$labels = array_merge((array)$autoLabels, (array)$customLabels);
$this->extend('updateFieldLabels', $labels);
return array_merge((array)$autoLabels, (array)$customLabels);
return $labels;
}
/**

View File

@ -137,6 +137,20 @@ abstract class DataObjectDecorator extends Extension {
}
}
/**
* this function is used to provide modifications to the fields labels in CMS
* by the decorator
* By default, the fieldLabels() of its owner will merge more fields defined in the decorator's
* $extra_fields['field_labels']
*/
function updateFieldLabels(&$lables){
$extra_fields = $this->extraDBFields();
if(isset($extra_fields['field_labels'])){
$field_labels = $extra_fields['field_labels'];
if($field_labels) $lables = array_merge($lables, $field_labels);
}
}
function updateSummaryFieldsExcludeExtra(&$fields){
$extra_fields = $this->extraDBFields();
if(isset($extra_fields['summary_fields'])){