In Silverstripe 3.1 adding fields to $summary_fields
in the extension is the correct way to do this.
The following code worked for me:
class OptionCost extends DataExtension {
private static $db = array(
'Cost' => 'Decimal(19,4)'
);
private static $summary_fields = array(
'Cost'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', new PriceField('Cost'));
return $fields;
}
}
Declare the extension in your config or in a config yaml file.
config.yml
...
Attribute:
extensions:
- OptionCost
...
Run a dev/build?flush=all
.
Also make sure you call ?flush=all
on your admin page.