Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » Issues when using UploadField

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

Page: 1
Go to End
Author Topic: 415 Views
  • Nobi
    Avatar
    Community Member
    5 Posts

    Issues when using UploadField Link to this post

    I am using UploadField on a Dataobject editor with getCMSFields()

    There is some issues when Create New Data. I upload a file when this new data have not been save. Its shows success upload like the screenshot I've attached.

    But when, I back to the Grid list form, then I edit the last created data, it is show me no image uploaded in UploadField input.

    I don't know why, but I guess the first image uploaded failed to linked to Dataobject because it's don't yet exist. When I save it, the Dataobject ID was created, and when I upload an image it success to linked Dataobject ID and Image file ID.

    Its supposed to be an easy task, I just want to disabled UploadField when the data has not been created yet, but in SS 3.0 I doesn't have idea how to do this ?

    Can anyone help me to solved this ?

    Thanks.

    Attached Files
  • lx
    Avatar
    Community Member
    82 Posts

    Re: Issues when using UploadField Link to this post

    You are right, the uploadfield doesnt support to add an image to a dataobject that does not yet exist.
    I hope this feature will be added in the future. Bye i talked to zauberfisch , the author of uploadfield, in irc about it. He said that would like to add this feature but has not enough time to do it at the moment.

    So what you can do is:

    If ($this->ID) {
    New uploadfield();
    }
    Else {
    New readonlyfield(...., "you need to save this record, before you can add an image");
    }

  • Johan
    Avatar
    Community Member
    49 Posts

    Re: Issues when using UploadField Link to this post

    It should work well enough and If you do not want the items to go live without an image then I guess a quick fix would be:

    <% if Image %>

    <!-- content here -->

    <% else %>
    <% end_if %>

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