Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught Exception BadMethodCallException: "Items must be saved before adding to a changeset" #190

Open
schrattenholz opened this issue Mar 6, 2019 · 0 comments
Labels

Comments

@schrattenholz
Copy link

schrattenholz commented Mar 6, 2019

Hi I get that error using BulkUploader in SS4.3

Uncaught Exception BadMethodCallException: "Items must be saved before adding to a changeset"

That s my gridfield-config

$gridFieldConfig=GridFieldConfig::create()
->addComponent(new GridFieldButtonRow('before'))
->addComponent($dataColumn=new GridFieldDataColumns)
->addComponent(new GridFieldDeleteAction())
->addComponent(new GridFieldEditButton())
->addComponent(new GridFieldDetailForm())
->addComponent(new GridFieldSortableHeader())
->addComponent(new GridFieldFilterHeader())
->addComponent(new GridFieldPaginator())
->addComponent(new GridFieldAddNewButton())
->addComponent($bulkUploader=new \Colymba\BulkUpload\BulkUploader('Image'))

The DataObject

use Silverstripe\ORM\DataObject;
use Silverstripe\Assets\Image;

class GalleryImage extends DataObject{
	private static $table_name="galleryimage";
	private static $db=[
		"SortID"=>"Int"
	];
	private static $has_one=[
		"Image"=>Image::class,
	];
	private static $belongs_many_many=[
		"Galleries"=>Gallery::class
	];
	public function onAfterWrite()
	{
			$this->Image()->doPublish();
	}
	public function getThumbnail(){
		return $this->Image()->CMSThumbnail();
	}
}	
		;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants