Hello
I've encountered a similar problem which neither of these solutions seem to solve for me (SS 3.0.3), any timely guidance much appreciated...
this is the error when viewing the StoreImage tab in CMS: [User Error] Uncaught Exception: Unable to traverse to related object field [ImageThumbnail] on [StoreImage]
Be aware, I'm noting particularly the notice 'user error' here : )
Further, its working perfectly when called from the related Product DataObject, ie, the thumbnail is showing in the Product Tab section
this is the setup:
Both of the following DataObjects are setup as Managed Models as defined in: class ProductAdmin extends ModelAdmin
StoreImage.php
class StoreImage extends DataObject {
public static $db = array(
'SortOrder' => 'Int',
'Title' => 'Varchar',
'Type' => "Enum('Product Image, Producer Image, Category Image')"
);
// One-to-one relationship with product object
public static $has_one = array(
'Image' => 'Image',
'Product' => 'Product'
);
// tidy up the CMS by not showing these fields
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeByName('SortOrder');
$fields->removeByName('ProductID');
return $fields;
}
// this function creates the thumbnail for the summary fields to use
public function ImageThumbnail() {
return $this->Image()->SetHeight(50);
}
// Tell the datagrid what fields to show in the table
public static $summary_fields = array(
'Title' => 'Title',
'Type' => 'Type',
'ImageThumbnail' => 'Thumbnail'
);
Product.php
class Product extends DataObject {
static $db = array('Name' => 'Varchar', 'Description' => 'Text','ProductCode' => 'Varchar', 'Price' => 'Currency');
static $has_one = array('ProductCategory' => 'ProductCategory', 'StoreImage' => 'StoreImage', 'ProductProducer' => 'ProductProducer', 'ProductPage' => 'ProductPage');
// For search in CMS
static $searchable_fields = array(
'Name',
'ProductCode'
);
static $summary_fields = array(
'Name' => 'Name',
'StoreImage.ImageThumbnail' => 'Product Image',
'Description' => 'Description',
'Price' => 'Price'
);
Thanks for looking!