Hi there,
I'm having issues with SilverStripe backend image upload to a specific dataobject ID.
"Files can be attached once you have saved the record for the first time."
I want to attach the file before creating the record. I've tried using Uploadify but Uploadify has no support for SilverStripe 3. I've tried porting Uploadify for old SilverStripe version to SilverStripe 3 but that was very messy.
Screenshot:
Code example for this simple gallery module:
<?php
/*
* Gallery & Images DataStructure with ModelAdmin enabled in the CMS.
* ModelAdmin called: Gallery & Images
*/
class Gallery extends DataObject {
static $db = array(
"Name"=>"Varchar(255)",
"DateTime"=>"SS_DateTime",
);
static $has_many = array(
"GalleryImages" => "GalleryImages",
);
}
class GalleryImages extends DataObject {
static $db = array(
"Name"=>"Varchar(255)",
"Description"=>"Text",
);
static $has_one = array(
"Gallery" => "Gallery",
"galleryImage" => "Image",
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeByName("galleryImage");
$fields->addFieldToTab("Root.Main", $if = new UploadField('galleryImage','Gallery Images'));
$if->setConfig('allowedMaxFileNumber', 500)->setFolderName('gallery/gallaryimg');
$if->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
return $fields;
}
}
class GalleryImagesModelAdmin extends ModelAdmin {
public static $managed_models = array('Gallery','GalleryImages');
static $url_segment = 'GalleryImages';
static $menu_title = 'Gallery & Images';
}
?>
Any pointers would be greatly appreciated.
Thanks.