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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

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


Go to End


4 Posts   3060 Views

Avatar
brokemeister

Community Member, 30 Posts

27 July 2009 at 10:17pm


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

Avatar
brokemeister

Community Member, 30 Posts

27 July 2009 at 10:27pm

With

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

it also does not work work...

Cheers,
Malte

Avatar
brokemeister

Community Member, 30 Posts

27 July 2009 at 11:02pm

I have found problem.

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

Cheers,

Malte

Avatar
BLU42 Media

Community Member, 71 Posts

1 October 2009 at 9:33am

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!!