Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » More info on error

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 439 Views
  • Shelly
    Avatar
    Community Member
    3 Posts

    More info on error Link to this post

    The error message I'm getting is:

    I could not find the relation Resources in ResearchGroupPage or any of its ancestors.

    The problem seems to be coming from section of code starting at line 29 in ManyManyDataObjectManager.php
          foreach($classes as $class) {
             if($class != "Object") {

    Here's the relevant code from my DataObjectAsPage files:

    ----

    class ResourceItem extends DataObjectAsPage {
    //The class of the page which will list this DataObject
    static $listing_class = 'ResourcePage';
    //Class Naming (optional but recommended)
    static $plural_name = 'ResourceItems';
    static $singular_name = 'ResourceItem';
       
       public static $db = array(
          'Date'          => 'SS_Datetime',
          'PublicAccess'    => 'Boolean',
          'Directory'    => 'Text',
          'URI'          => 'Text',
          'ResourceType'    => "Enum(array('Web', 'File'), 'Web')",
       );
       
       public static $has_one = array(
          'Owner' => 'Member',
          'ResourceFile' => 'File'
       );
          
       public static $many_many = array(
        'Tags' => 'Tag',
       );

       public static $belongs_many_many = array (
          'ResearchGroups' => 'ResearchGroup'
       );

    ------

    class ResearchGroup extends DataObjectAsPage {
    //The class of the page which will list this DataObject
    static $listing_class = 'ResearchGroupPage';
    //Class Naming (optional but recommended)
    static $plural_name = 'ResearchGroups';
    static $singular_name = 'ResearchGroup';
       
       
       public static $has_one = array(
          'Creator' => 'Member'
       );
          
       public static $many_many = array(
          'Members'      => 'Member',
          'Resources'   => 'ResourceItem',
          'Journals'      => 'JournalEntry',
          'Publications'   => 'Publication'
       );
    .......

    class ResearchGroupPage extends DataObjectAsPageHolder {

    }

    class ResearchGroupPage_Controller extends DataObjectAsPageHolder_Controller {

    // Here's the relevant part of the form I'm trying to display on the edit page for a Research Group

       function ResearchGroupForm() {         
          // Must be logged in
          $member = MEMBER::CurrentMember();
          if (!$member) {
             return Security::permissionFailure($this);
          }

          //Create form fields
          $fields = new FieldSet (
             new HiddenField("ID", "ID"),
             new HiddenField("CreatorID", "CreatorID"),
             new TextField('Title', 'Title'),
             new HTMLEditorField('Content', 'Description'),
             $resources = new ManyManyDataObjectManager (
                $this, // Controller
                'Resources', // Source name
                'ResourceItem', // Source class
                array(
                   'Title' => 'Title',
                   'Content' => 'Content'
                ),
                'getCMSFields'
             )
          );

    ---------------------------------

    Thanks, Shelly

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