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

Fatal error in ModelAdmin


4 Posts   1151 Views


12 July 2010 at 4:15am Community Member, 33 Posts

I am getting the follwing error in ModelAdmin 2.4:

Fatal error: Call to a member function getModelSidebar() on a non-object in cms/code/ModelAdmin.php on line 251:

'Content' => $this->$class->getModelSidebar()

   protected function getModelForms() {
      $models = $this->getManagedModels();
      $forms = new DataObjectSet();
      foreach($models as $class => $options) {
         if(is_numeric($class)) $class = $options;
         $forms->push(new ArrayData(array (
            'Title' => (is_array($options) && isset($options['title'])) ? $options['title'] : singleton($class)->i18n_singular_name(),
            'ClassName' => $class,
            'Content' => $this->$class->getModelSidebar()
      return $forms;

I do not understand this. Does anybody know, why this happens and what I can do to make it work?


12 July 2010 at 5:27am Forum Moderator, 1796 Posts


It is tough to solve without the code that is causing the error - believe me ModelAdmin is stable. My first guess would be that you have misspelled one of the static $managed_models = array('nonexistentdataobject','mispelleddataobject'); - if you cannot see any errors there (and you are sure all your data bojects are loading e.g. the FileName.php matches the class FileName extends DataObject()) then post the code of the model admin and data objects managed and maybe I can be more help.



12 July 2010 at 9:29am Community Member, 33 Posts

OMG! My code was ok... The problem was that I've used in one of my classes a reserved word. Renaming it solved it. Thanks for your help.


1 September 2010 at 12:28am Forum Moderator, 1796 Posts

I just had a similar issue, found this thread so I thourght I'd add mine to it... I had a mangaed_model called 'XYZ' and then I defined a function within the ModelAdmin called 'XYZ'. Renaming the function sorted it all out...