Jump to:

23371 Posts in 18161 Topics by 2865 members

General Questions

SilverStripe Forums » General Questions » Attaching same image to several dtaobjects

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

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

Page: 1
Go to End
Author Topic: 396 Views
  • Lukin
    Avatar
    Community Member
    42 Posts

    Attaching same image to several dtaobjects Link to this post

    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

  • Robke
    Avatar
    Community Member
    4 Posts

    Re: Attaching same image to several dtaobjects Link to this post

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

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