Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Bug Reports

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
Go to End
Author Topic: 44453 Views
  • Mad_Clog
    Avatar
    Community Member
    78 Posts

    Re: Bug Reports Link to this post

    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'
             )
          );

  • hive.net.au
    Avatar
    Community Member
    40 Posts

    Re: Bug Reports Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Bug Reports Link to this post

    What version of DOM?

  • hive.net.au
    Avatar
    Community Member
    40 Posts

    Re: Bug Reports Link to this post

    Revision: #399

  • MarijnKampf
    Avatar
    Community Member
    161 Posts

    Re: Bug Reports Link to this post

    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');
       }
    }

  • Mat Weir
    Avatar
    Community Member
    33 Posts

    Re: Bug Reports Link to this post

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

  • MarijnKampf
    Avatar
    Community Member
    161 Posts

    Re: Bug Reports Link to this post

    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:

  • UncleCheese
    Avatar
    4085 Posts

    Re: Bug Reports Link to this post

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

    44453 Views
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
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.