Jump to:

23358 Posts in 18066 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Fatal error in ModelAdmin

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

Page: 1
Go to End
Author Topic: 1126 Views
  • sonet
    Avatar
    Community Member
    33 Posts

    Fatal error in ModelAdmin Link to this post

    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?

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: Fatal error in ModelAdmin Link to this post

    Hi,

    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.

    Barry

  • sonet
    Avatar
    Community Member
    33 Posts

    Re: Fatal error in ModelAdmin Link to this post

    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.

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: Fatal error in ModelAdmin Link to this post

    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...

    1126 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.