I'm using public function fieldLabels()
in my DataObject to translate all field labels (as well as the labels for $summary_fields
). This works fine for all fields, except one that has a value returned from a function (rather than value extracted from database).
Summary Fields
static $summary_fields = array(
'Label' => 'Label',
'Type' => 'Type',
'getRequiredLabel' => 'Required'
);
FieldLabels
public function fieldLabels($includerelations = true) {
$labels = parent::fieldLabels(true);
$labels['Label'] = _t('UserForm.Label', 'Label');
$labels['Type'] = _t('UserForm.Type', 'Type');
$labels['Required'] = _t('UserForm.Required', 'Required');
return $labels;
}
All fields are neatly translated through fieldLabels()
except for Required because this has a custom value from a function rather than from data. Changing getRequiredLabel to Required fixes this.
Any way I can keep the value getRequiredLabel for the record fields and have the translated label in the top column?