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

Attaching same image to several dtaobjects


Go to End


2 Posts   1173 Views

Avatar
Lukin

Community Member, 56 Posts

27 September 2012 at 12:42am

Edited: 27/09/2012 12:44am

Hi

I have an DataOject icluding an image file.
Once I ve uploaded the image I want to use it in multiple DataObject of the same Class.

But I alway get 'Forbidden' attaching the file to another dataobject.

I tried to set up a relation but it does not help:

class Bild extends DataObject{
	
	static $db=array(
		'Beschreibung'=>'Text'
	);
	public static $has_one = array(
    	'Attachment' => 'CustomImage'
  	);
	public static $belongs_many_many = array (
		'Pages'=>'Page'
	);
	static $summary_fields = array(
      'Attachment.StripThumbnail' => '',
      'Beschreibung' => 'Beschreibung'
   ); 
 	public function getCMSFields_forPopup() {
 
    // Profile picture field
    $bild = new UploadField('Attachment');
    $bild->allowedExtensions = array('jpg', 'png', 'gif');
 
    // Name, Description and Website fields
    return new FieldList(
      new TextField('Beschreibung', 'Beschreibung'),
      $bild
    );
  }
	
}



class CustomImage extends Image{
	  
	public static $has_many=array(
		'Bilder'=>'Bild'
	);  
	  
  }

Version is 3.0.2
What s wrong?

Thanks in advance
Lukin

Avatar
Robke

Community Member, 4 Posts

21 May 2013 at 1:19am

did you found a solution, because i have the sae issue?