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

Making it Nice


Reply


4 Posts   428 Views

Avatar
cumquat

Community Member, 198 Posts

25 April 2013 at 9:04pm

Hi guys,

Ok i'm using version 3.1 beta 3 and am trying to display the value of a boolean and also of a date field 'Nice' in a model admin page. I used to use the code below to do this but now i get 'unable to transverse' errors, any pointers?

public static $summary_fields = array(
      'NiceShow' => 'Show Live'
      
   );

public function getNiceShow() {
      return $this->obj('Visible')->Nice();
   }

Cheers

Mick

Avatar
Sean

Forum Moderator, 922 Posts

26 April 2013 at 10:54am

Could you paste in the actual error and error backtrace?

Avatar
kinglozzer

Community Member, 175 Posts

26 April 2013 at 8:17pm

Try setting private static $searchable_fields = array();. It may have been fixed before beta3, but there was previously a bug which meant that $summary_fields wouldn't work without $searchable_fields being defined.

Avatar
cumquat

Community Member, 198 Posts

26 April 2013 at 8:41pm

Hi there,

I have $searchable_fields still no go. below is the error details i get.

[User Error] Uncaught Exception: Unable to traverse to related object field [NiceShow] on [MarketDate]
GET /admin/MarketAdmin/?flush=1
Line 2669 in /home/sites/xxxxxxxxxxxxx/framework/model/DataObject.php
Source
2660
2661       } else {
2662          $object = $this->dbObject($fieldPath);
2663       }
2664
2665
2666       if (!($object instanceof DBField) && !($object instanceof DataList)) {
2667          // Todo: come up with a broader range of exception objects to describe differnet kinds of errors
2668          // programatically
2669          throw new Exception("Unable to traverse to related object field [$fieldPath] on [$this->class]");
2670       }
2671       return $object;
2672    }
2673
2674    /**
2675     * Traverses to a field referenced by relationships between data objects, returning the value
Trace
DataObject->relObject(NiceShow)
DataObject.php:1944
DataObject->scaffoldSearchFields()
DataObject.php:1889
DataObject->getDefaultSearchContext()
ModelAdmin.php:189
ModelAdmin->getSearchContext()
ModelAdmin.php:204
ModelAdmin->SearchForm()
ViewableData.php:363
ViewableData->obj(SearchForm,,,1)
ViewableData.php:436
ViewableData->XML_val(SearchForm,,1)
call_user_func_array(Array,Array)
SSViewer.php:156
SSViewer_Scope->__call(XML_val,Array)
SSViewer.php:502
SSViewer_DataPresenter->__call(XML_val,Array)
.cache.framework.admin.templates.Includes.ModelAdmin_Tools.ss:10
SSViewer_DataPresenter->XML_val(SearchForm,,1)
.cache.framework.admin.templates.Includes.ModelAdmin_Tools.ss:10
include(/home/sites/xxxxxxxxxxxxx/silverstripe-cache/xxxxxx/.cache.framework.admin.templates.Includes.ModelAdmin_Tools.ss)
SSViewer.php:894
SSViewer->includeGeneratedTemplate(/home/sites/xxxxxxxxx/silverstripe-cache/xxxxxxxxxxxxxxx/.cache.framework.admin.templates.Includes.ModelAdmin_Tools.ss,MarketAdmin,,Array)
SSViewer.php:960
SSViewer->process(MarketAdmin)
LeftAndMain.php:1274
LeftAndMain->Tools()
ViewableData.php:363
ViewableData->obj(Tools,,,1)
ViewableData.php:436
ViewableData->XML_val(Tools,,1)
call_user_func_array(Array,Array)
SSViewer.php:156
SSViewer_Scope->__call(XML_val,Array)
SSViewer.php:502
SSViewer_DataPresenter->__call(XML_val,Array)
.cache.framework.admin.templates.Includes.ModelAdmin_Content.ss:78
SSViewer_DataPresenter->XML_val(Tools,,1)
.cache.framework.admin.templates.Includes.ModelAdmin_Content.ss:78
include(/home/sites/xxxxxxxxxx/silverstripe-cache/xxxxxxxx/.cache.framework.admin.templates.Includes.ModelAdmin_Content.ss)
SSViewer.php:894
SSViewer->includeGeneratedTemplate(/home/sites/xxxxxxxxxx/silverstripe-cache/xxxxxxxxxxxxxx/.cache.framework.admin.templates.Includes.ModelAdmin_Content.ss,MarketAdmin,,Array)
SSViewer.php:960
SSViewer->process(MarketAdmin,)
ViewableData.php:336
ViewableData->renderWith(Array)
LeftAndMain.php:666
LeftAndMain->Content()
ViewableData.php:363
ViewableData->obj(Content,,,1)
ViewableData.php:436
ViewableData->XML_val(Content,,1)
call_user_func_array(Array,Array)
SSViewer.php:156
SSViewer_Scope->__call(XML_val,Array)
SSViewer.php:502
SSViewer_DataPresenter->__call(XML_val,Array)
.cache.framework.admin.templates.LeftAndMain.ss:36
SSViewer_DataPresenter->XML_val(Content,,1)
.cache.framework.admin.templates.LeftAndMain.ss:36
include(/home/sites/xxxxxxxx/silverstripe-cache/xxxxxxxxxxxxx/.cache.framework.admin.templates.LeftAndMain.ss)
SSViewer.php:894
SSViewer->includeGeneratedTemplate(/home/sites/xxxxxxxxx/silverstripe-cache/xxxxxxxxxxxxx/.cache.framework.admin.templates.LeftAndMain.ss,MarketAdmin,,Array)
SSViewer.php:960
SSViewer->process(MarketAdmin,)
ViewableData.php:336
ViewableData->renderWith(SSViewer)
LeftAndMain.php:541
{closure}()
call_user_func(Closure)
PjaxResponseNegotiator.php:75
PjaxResponseNegotiator->respond(SS_HTTPRequest)
LeftAndMain.php:447
LeftAndMain->index(SS_HTTPRequest)
RequestHandler.php:278
RequestHandler->handleAction(SS_HTTPRequest,index)
Controller.php:194
Controller->handleAction(SS_HTTPRequest,index)
RequestHandler.php:190
RequestHandler->handleRequest(SS_HTTPRequest,DataModel)
Controller.php:153
Controller->handleRequest(SS_HTTPRequest,DataModel)
LeftAndMain.php:397
LeftAndMain->handleRequest(SS_HTTPRequest,DataModel)
AdminRootController.php:89
AdminRootController->handleRequest(SS_HTTPRequest,DataModel)
Director.php:325
Director::handleRequest(SS_HTTPRequest,Session,DataModel)
Director.php:143
Director::direct(/admin/MarketAdmin/,DataModel)
main.php:128