Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Uncaught Exception: Unable to traverse to related object field


Go to End


2 Posts   1502 Views

Avatar
ScottT

Community Member, 9 Posts

11 May 2012 at 7:28am

Hi Folks,
I have the class below and am getting the error in the title. I have read other posts about this, but the problem does not seem related to the $searchable_fields array as you can see from the code:

The full error is

Error at sapphire/core/model/DataObject.php line 2492: Uncaught Exception: Unable to traverse to related object field [CDSEquivalent] on [SiennaEmploymentStatusCategory

class SiennaEducationalStatusCategory extends SiennaViewableData { //which extends DataObject
	
	public static $db = array (
			'EducationalStatusCategory' => 'Varchar(255)',
			'EducationalStatusCategoryDetails' => 'HTMLText',
			
			);
	
	public static $has_one = array (
			'CDSEquivalent' => 'SiennaCDSCategory',
			);
	
	//public static $has_many = array (
	//		'EducationalStatusRecords' => 'SiennaEducationalStatus',
	//		);
	
	public static $searchable_fields = array (
			'ID',
			'EducationalStatusCategory',
			'EducationalStatusCategoryDetails'
			);
	
	public static $summary_fields = array (
			'ID',
			'EducationalStatusCategory',
			'EducationalStatusCategoryDetails',
			);
	
	public static $singular_name = 'Education Status Category'; 
}

Please help!!

Avatar
ScottT

Community Member, 9 Posts

11 May 2012 at 8:01am

Never mind. I was not reading the error messages closely enough. The error was the same as has been posted about before.

The comments to DataObject (line 2492) also explain the correct syntax if you with to include a $has_one field in a $searchable_fields array.