From 1fb4c6f39f5252850267e91bacde0b43ca0b3125 Mon Sep 17 00:00:00 2001 From: John Milmine Date: Wed, 6 Dec 2017 23:00:15 +1300 Subject: [PATCH] Correcting docs around summary field relabelling Although this is weird that it doesn't use the same logic and searchable fields. --- .../00_Model/11_Scaffolding.md | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/en/02_Developer_Guides/00_Model/11_Scaffolding.md b/docs/en/02_Developer_Guides/00_Model/11_Scaffolding.md index 298e230a8..415ca9715 100644 --- a/docs/en/02_Developer_Guides/00_Model/11_Scaffolding.md +++ b/docs/en/02_Developer_Guides/00_Model/11_Scaffolding.md @@ -227,6 +227,32 @@ class MyDataObject extends DataObject ``` +In order to re-label any summary fields, you can use the $field_labels static. + +```php +use SilverStripe\ORM\DataObject; + +class MyDataObject extends DataObject +{ + private static $db = [ + 'Name' => 'Text', + ]; + + private static $has_one = [ + 'HeroImage' => 'Image', + ]; + + private static $summary_fields = [ + 'Name', + 'HeroImage.CMSThumbnail', + ]; + + private static $field_labels = [ + 'Name' => 'Name', + 'HeroImage.CMSThumbnail' => 'Hero', + ]; +} + ## Related Documentation * [SearchFilters](searchfilters)