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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

What means: Unable to traverse to related object field


Reply


2 Posts   2307 Views

Avatar
dacar

Community Member, 168 Posts

15 August 2009 at 3:14am

Hi, can anybody explain what this trace is talking about?

[User Error] Uncaught Exception: Unable to traverse to related object field [Ansprechpartner.Nachname] on [Stammdaten]
GET /silverstripe/admin/Kunden/

Line 2204 in /home/31/cwretaid/silverstripe/sapphire/core/model/DataObject.php
Source

2195          } elseif($info = $this->castingHelperPair($relation)) {
2196             $component = singleton($info['className']);
2197          }
2198       }
2199
2200       $object = $component->dbObject($fieldName);
2201
2202       if (!($object instanceof DBField) && !($object instanceof ComponentSet)) {
2203          // Todo: come up with a broader range of exception objects to describe differnet kinds of errors programatically
2204          throw new Exception("Unable to traverse to related object field [$fieldPath] on [$this->class]");
2205       }
2206       return $object;
2207    }
2208
2209    /**
2210     * Temporary hack to return an association name, based on class, to get around the mangle

Trace

* DataObject->relObject(Ansprechpartner.Nachname)
Line 1645 of DataObject.php
* DataObject->scaffoldSearchFields()
Line 1591 of DataObject.php
* DataObject->getDefaultSearchContext()
Line 317 of ModelAdmin.php
* ModelAdmin_CollectionController->SearchForm()
Line 194 of ModelAdmin.php
* ModelAdmin->getModelForms()
Line 107 of ViewableData.php
* ViewableData->__get(ModelForms)
Line 320 of ViewableData.php
* ViewableData->obj(ModelForms)
Line 23 of .cache.home.31.cwretaid.silverstripe.cms.templates.Includes.ModelAdmin_left.ss
* include(/home/31/cwretaid/silverstripe/silverstripe-cache/.cache.home.31.cwretaid.silverstripe.cms.templates.Includes.ModelAdmin_left.ss)
Line 354 of SSViewer.php
* SSViewer->process(KundenAdmin)
Line 773 of ViewableData.php
* ViewableData->renderWith(Array)
Line 480 of LeftAndMain.php
* LeftAndMain->Left()
* call_user_func_array(Array,Array)
Line 408 of ViewableData.php
* ViewableData->XML_val(Left,,1)
Line 59 of .cache.home.31.cwretaid.silverstripe.cms.templates.LeftAndMain.ss
* include(/home/31/cwretaid/silverstripe/silverstripe-cache/.cache.home.31.cwretaid.silverstripe.cms.templates.LeftAndMain.ss)
Line 354 of SSViewer.php
* SSViewer->process(KundenAdmin)
Line 175 of Controller.php
* Controller->handleAction(HTTPRequest)
Line 129 of RequestHandler.php
* RequestHandler->handleRequest(HTTPRequest)
Line 122 of Controller.php
* Controller->handleRequest(HTTPRequest)
Line 277 of Director.php
* Director::handleRequest(HTTPRequest,Session)
Line 121 of Director.php
* Director::direct(/admin/Kunden/)
Line 118 of main.php

Avatar
dalesaurus

Community Member, 283 Posts

15 August 2009 at 4:32am

Edited: 19/08/2009 5:26am

Looks like you're using the scaffolding to enable searching on fields. You're trying to add a field that is a foreign key of another table as one of the $searchable_fields vars.

You need to fully qualify the Field of the related table in $searchable_fields or you will get the "Unable to traverse Object" error.

Example

static $has_one = array(
'CreatedByMember' => 'Member'
);

static $searchable_fields = array(   
                     'Title' => 'PartialMatchFilter',
                     'CreatedByMember.Email' => 'PartialMatchFilter',
                  );

See full documentation at http://doc.silverstripe.com/doku.php?id=dataobject#searchable_fields