Jump to:

23450 Posts in 18899 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Image Relationship

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: 294 Views
  • clauddiu
    Community Member
    5 Posts

    Image Relationship Link to this post


    I have this code where I have to upload some data and a file, the data is showing when I parse it but not the file.. this is my code, if anyone can please tell me what I do wrong I will really apreciate it.



    class HomePage extends SiteTree {


    class HomePage_Controller extends Page_Controller {

    public function init() {

    public function SubmitForm() {
    $form = new Form (
    new FieldList (
    new DropdownField('Workspace', _t('UploadItem.WORKSPACE','Workspace'), singleton('UploadItem')->dbObject('Workspace')->enumValues()),
    new TextareaField('Description', _t('UploadItem.DESCRIPTION','Description')),
    new UploadField('uFiles', _t('UploadItem.UFILES','Upload File'))
    new FieldList (
    new FormAction('doApply', _t('UploadItem.APPLYNOW','Save'))
    //, new RequiredFields('Description','UploadFile')

    return $form;

    public function doApply($data, $form) {
    $submission = new UploadItem();
    return $this->redirectBack();

    public function showFiles() {
    return UploadItem::get();




    class UploadItem extends DataObject {
    static $db = array(
    'Description' => 'Text',
    'Workspace' => "Enum('First Project, Second Project, Other Project')"

    static $has_one = array(
       'uFiles' => 'File'


       <% loop showFiles %>
       <li>Description: $Description in $Workspace, File <br />
          Link: $uFiles.Link <br />
          Filename: $uFiles.Name <br />
          URL: $uFiles.URL </br />

       <% end_loop %>

    I try to make this work for like 2 days, please guys give me a hint.

    Thank you,

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.