Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » CheckboxSetField: [User Error] ... the method 'setbyidlist' does not exist on 'DataObjectSet'

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: 2336 Views
  • brokemeister
    Avatar
    Community Member
    30 Posts

    CheckboxSetField: [User Error] ... the method 'setbyidlist' does not exist on 'DataObjectSet' Link to this post

    Hi!

    The Edit-Form for my ContentDataObject (in the DataObjectManager) works fine, but if I want to save it, following exception is thrown:

    [User Error] Uncaught Exception: Object->__call(): the method 'setbyidlist' does not exist on 'DataObjectSet'
    POST /admin/EditForm/field/CurrentContent/item/47/DetailForm

    Line 515 in ~/sapphire/core/Object.php
    Source

    506             case isset($config['function']) :
    507                return $config['function']($this, $arguments);
    508             
    509             default :
    510                throw new Exception (
    511                   "Object->__call(): extra method $method is invalid on $this->class:" . var_export($config, true)
    512                );
    513          }
    514       } else {
    515          throw new Exception("Object->__call(): the method '$method' does not exist on '$this->class'");
    516       }
    517    }
    518    
    519    // -----------------------------------------------------------------------------------------------------------------
    520    
    521    /**

    Trace

    * Object->__call(setByIDList,Array)
    * DataObjectSet->setByIDList(Array)
    Line 143 of CheckboxSetField.php
    * CheckboxSetField->saveInto(EventDataObject)
    Line 884 of Form.php
    ....

    I have follow DataObjects

    class ContentDataObject extends MagazinDataObject {
       
       static $db = array (
       );
       
       static $has_many = array (
       );
       
       static $many_many = array (
          "Categories" => "CategoryDataObject",
       );

       
       public function getCMSFields_forPopup() {
          $fields = parent::getCMSFIelds_forPopup();
          
          $fields->push(new DateField("ArchivDate", "Archivierungsdatum"));
          $fields->push(new DropdownField("ClassName", $this->fieldLabel('ClassName'), $this->getContentTypeClasses('ContentDataObject')));
          $contentList = DataObject::get('CategorizationComplexDataObject');
    //      $fields->push(new CategorizationSetField("Categories", "Kategorien", $contentList));
          $fields->push(new CheckboxSetField("Categories", "Kategorien", $contentList->toDropDownMap()));
          return $fields;
       }
    ...
    }

    class CategorizationDataObject extends MagazinDataObject {
       
       static $db = array (
       );
       
       static $has_one = array(
       );
       
       static $belongs_many_many = array (
          "Contents" => "ContentDataObject",
       );
       
       
       public function getCMSFields_forPopup() {
          $fields = parent::getCMSFields_forPopup();
          $fields->push(new DropdownField("ClassName", $this->fieldLabel('ClassName'), $this->getContentTypeClasses('CategorizationDataObject')));
          
          $fields->push(new DropdownField("MagazinPageID", "Single View Page", $this->getMagazinPagesForDropDown()));
          
    //      $fields->push(new TextField("Author", "Autor"));
          return $fields;
       }
    ...
    }

    Any ideas or hints?

    Cheers,

    Malte

  • brokemeister
    Avatar
    Community Member
    30 Posts

    Re: CheckboxSetField: [User Error] ... the method 'setbyidlist' does not exist on 'DataObjectSet' Link to this post

    With

    static $many_many = array (
    "Categories" => "CategorizationDataObject",
    );
    ...


    it also does not work work...

    Cheers,
    Malte

  • brokemeister
    Avatar
    Community Member
    30 Posts

    Re: CheckboxSetField: [User Error] ... the method 'setbyidlist' does not exist on 'DataObjectSet' Link to this post

    I have found problem.

    I have overwritten the automatically generated Categories-function with my custom one.
    Stupid mistake...

    Cheers,

    Malte

  • BLU42 Media
    Avatar
    Community Member
    71 Posts

    Re: CheckboxSetField: [User Error] ... the method 'setbyidlist' does not exist on 'DataObjectSet' Link to this post

    I was running into the same issue... so I thought I'd share my findings with anyone else who may run into the same issue.

    If you do need to overwrite the auto-generated function, you could try something like this in your DataObject:

    // Code you want but can't use in this situation:
    return DataObject::get('<YourObject>', "<filter>", "<sort>", etc);

    return $this->getManyManyComponents('<YourRelation>', "<filter>", "<sort>", etc);

    You could use getComponents or getHasManyComponents too.

    Hope it helps someone!!

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