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

Bug Reports


Go to End
Reply


297 Posts   52383 Views

Avatar
Mad_Clog

Community Member, 78 Posts

10 June 2010 at 4:01am

Edited: 16/06/2010 7:36pm

Bug in HasManyDataObjectManager

   public static $summary_fields = array(
      'Rating' => 'Rating',
      'Member.Email' => 'Email'
   );

SQL error: Unknown field Member.Email in fieldlist

      $oFieldSet->addFieldToTab(
         'Root.Ratings',
         new HasManyDataObjectManager(
            $this,
            'Ratings',
            'Rating'
         )
      );

Works fine:

      $oFieldSet->addFieldToTab(
         'Root.Ratings',
         new HasManyComplexTableField(
            $this,
            'Ratings',
            'Rating'
         )
      );

Avatar
hive.net.au

Community Member, 40 Posts

10 June 2010 at 3:46pm

Hi Uncle Cheese,

Awesome Module,

I am having a small problem with the latest trunk build on the current 2.4 release.

When in Dev mode the ManyManyDataObjectManager generates the following error however when in live mode it works as expected.

[Warning] Missing argument 3 for ComplexTableField_Item::__construct(), called in /var/www/vhosts/xxxx.com/httpdocs/xxxx/dataobject_manager/code/DataObjectManager.php on line 585 and defined

GET /xxxx/admin?flush=1

Line 1004 in /var/www/vhosts/xxxx.com/httpdocs/xxxx/sapphire/forms/ComplexTableField.php

Any ideas, let me know if you need more information.

Avatar
UncleCheese

Forum Moderator, 4096 Posts

11 June 2010 at 1:45am

What version of DOM?

Avatar
hive.net.au

Community Member, 40 Posts

11 June 2010 at 10:48am

Revision: #399

Avatar
MarijnKampf

Community Member, 164 Posts

15 June 2010 at 1:37am

Edited: 15/06/2010 1:39am

Hi UncleCheese,

I'm trying to (mis)use ManyManyDataObjectManager to manage a relation on an extension of the Member class. However, I get the error:

[User Warning] Can't figure out the data class of
GET /testss/admin/security/EditForm/field/Members/item/2/edit

Line 28 in G:\localhost\testss\dataobject_manager\code\HasManyDataObjectManager.php


Also the SimpleHTMLEditorField doesn't work in the Members pop-up.

Below a simplified test case of the code. The ManyManyDataObjectManager in Page works find, it's the one on Members that breaks. This error doesn't have a high priority for me as I've found a work around from your thread on http://silverstripe.org/customising-the-cms/show/252445?start=0#post252457, but I thought I would report it to you anyway in case it affects other issues too.

Edit: I've tested this with the latest revision (399).

_config.php

DataObject::add_extension('Member', 'Expert');

mysite\code\Expert.php

<?php
class Expert extends Extension {
   static $singular_name = 'Expert';
   static $plural_name = 'Experts';

   function extraStatics() {
      return array(
         'db' => array(
            'Description' => 'HTMLText',
            'TitleName' => 'Text',
         ),
         'many_many' => array(
            'Pages' => 'Page',
         ),
         'has_one' => array(
          'Thumbnail' => 'Image'
         ),
      );
   }

   public function getCMSFields() {
      $fields = parent::getCMSFields();
   $this->extend('updateCMSFields', $fields);
   return $fields;
   }

   public function updateCMSFields(&$fields) {
$fields->addFieldToTab("Root.Main", new TextField('TitleName', 'Academic title'), "FirstName");
      $fields->addFieldToTab("Root.Description", new SimpleHTMLEditorField("Description", "Description"));

      //This does work and shows the many many relation is working
      $fields->addFieldToTab("Root.Pages",new CheckboxSetField('Pages','Pages (check all that apply)', DataObject::get("Page")->toDropdownMap()));

      $domPages = new ManyManyDataObjectManager($this, "Pages", "Page", array('Title' => 'Title'), "getCMSFields_forPopup", '', 'Surname ASC');
      $fields->addFieldToTab("Root.Pages", $domPages);

$fields->addFieldToTab("Root.Thumbnail", new ImageField('Thumbnail', 'Thumbnail'));
return $fields;
}

   function getCMSFields_forPopup() {
      $fields = new FieldSet(
         new TextField("Surname", "Surname")
      );
      return $fields;
   }
}

mysite/code/Page.php

<?php
class Page extends SiteTree {
   static $belongs_many_many = array(
      'Members' => 'Member',
   );

   function getCMSFields() {
      $fields = parent::getCMSFields();

      // It works fine from here
      $manager = new ManyManyDataObjectManager($this, "Members", "Member", array('Surname' => 'Surname'), "getCMSFields_forPopup", "", "Surname ASC");
      $manager->setPermissions(array());
$fields->addFieldToTab("Root.Content.Experts", $manager);

      return $fields;
   }

   function getCMSFields_forPopup() {
      $fields = new FieldSet(
         new TextField("Title", "Title")
      );
      return $fields;
   }
}

class Page_Controller extends ContentController {

   /**
    * An array of actions that can be accessed via a request. Each array element should be an action name, and the
    * permissions or conditions required to allow the user to access it.
    *
    * <code>
    * array (
    * 'action', // anyone can access this action
    * 'action' => true, // same as above
    * 'action' => 'ADMIN', // you must have ADMIN permissions to access this action
    * 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
    * );
    * </code>
    *
    * @var array
    */
   public static $allowed_actions = array (
   );

   public function init() {
      parent::init();

      // Note: you should use SS template require tags inside your templates
      // instead of putting Requirements calls here. However these are
      // included so that our older themes still work
      Requirements::themedCSS('layout');
      Requirements::themedCSS('typography');
      Requirements::themedCSS('form');
   }
}

Avatar
Mat Weir

Community Member, 33 Posts

15 June 2010 at 10:16am

@MarijnKampf, in Expert.php, try using:

domPages = new ManyManyDataObjectManager($this->owner,
...

As you're using a decorator, $this refers to the decorator, hence the DataObjectManager not being able to figure out the data class.

Avatar
MarijnKampf

Community Member, 164 Posts

15 June 2010 at 8:38pm

Thanks Mat that solved the error I was experiencing with the DOM module. I suspected it may have been a case of user error ;)

Unfortunately, the css for the DOM isn't applied correctly:

Avatar
UncleCheese

Forum Moderator, 4096 Posts

16 June 2010 at 1:27am

Make sure the module is installed in the directory "dataobject_manager"

Go to Top