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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

More info on error


Reply


527 Views

Avatar
Shelly

Community Member, 3 Posts

11 July 2012 at 2:10pm

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