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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Upload-image-editing screw up filemanager


Go to End


3 Posts   1309 Views

Avatar
Bereusei

Community Member, 96 Posts

18 October 2013 at 2:20am

Hey guys,

I´m following this little tutorial http://doc.silverstripe.org/framework/en/trunk/reference/uploadfield about extending the uploadfield in SS3.
Everything works really nice in front- and backend, but if I want to start the filemanager in the backend, I get this crazy error:
Fatal error: Call to undefined method ProductDetail::setSourceQueryParams() in /Applications/MAMP/htdocs/moebel-luebbering3/framework/model/DataList.php on line 678

class Product extends DataObject
{
...
        static $many_many = array(
		'ProductDetails' => 'Image'
	);
        ....
        
        public function getCMSFields() 
	{
               ...
               $uploadField = new UploadField('ProductDetails','Bilder'); 
		$uploadField->setFileEditFields('getCustomFields');
		$uploadField->setFolderName('Uploads/Products/' . $this->Categories()->First()->Title); 
		$fields->addFieldToTab("Root.Main", $uploadField);
        
		return $fields;         
        }
}

class ProductDetail extends DataExtension
{
    static $db = array (
        'Text1' => 'Text',
       ...
    );
 
    private static $belongs_many_many = array (
        'Product' => 'Product'
    );
 	
 	
 	function getCustomFields() { 
		$fields = new FieldList(); 
		$fields->push(new TextField('Text1')); 
		...
		
		return $fields; 
	}    
}

class ProductDetailExtension extends DataExtension { 
   private static $belongs_many_many = array('Product' => 'Product');
}

_config.php

Image::add_extension('ProductDetailExtension');
Image::add_extension('ProductDetail');

Any idea what´s going on? Did someone follow this tutorial, too?

Avatar
Bambii7

Community Member, 254 Posts

21 October 2013 at 12:24pm

Hmmm I haven't followed the tutoiral.

But I'm pretty sure you can drop the second dataextension.

Both ProductDetail and ProductDetailExtension and trying to add the same relationship belongs_many_many/Product.

Try removing Image::add_extension('ProductDetailExtension');

Avatar
Bereusei

Community Member, 96 Posts

23 October 2013 at 8:04pm

Thanks for response. I´ve changed some things in the code:

I´ve changed this:

static $many_many = array( 
      'ProductDetails' => 'Image' 
   );

to this:
static $many_many = array( 
      'ProductDetails' => 'ProductImage' 
   );

and add an ProductImage class:
class ProductImage extends Image {
	private static $extensions = array(
		'ProductDetail'
	);
}

I removed double relationship "belongs_many_many", but the filemanager still doesn´t work right.
If I click now on the folder "Uploads" in the filemanager, the system throw out internal server error.

I´m using an "$uploadField->setFolderName" where the system self creates folders. Maybe there is a problem with the permissions.
I´m checking later the code and permissions.