NetTalk Central

Author Topic: Clear photo field contents  (Read 2997 times)

ianburgess

  • Full Member
  • ***
  • Posts: 119
    • View Profile
    • Email
Clear photo field contents
« on: July 11, 2012, 02:52:46 AM »
I have a form with a file upload button that uploads a photo. The filename is saved in USE:Photo, and there is a "Display" control on the form that displays a thumbnail of the photo, and all works fine.

The problem is that I want a "Clear" button that removes the contents of the USE:Photo field.  I have put a button on the form and in the Client side embed, I have put:
USE:Photo=''
p_web.SSV('USE:Photo',USE:Photo)

I have also "RESET" the display of USE:Photo on the clear button.

When I click on the Clear button, the thumbnail and filename are cleared on screen, but when the form is Saved, the empty USE:Photo field is not saved, so when you reopen the form, the photo is still there.

What am I doing wrong?

Thanks

Ian

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Clear photo field contents
« Reply #1 on: July 11, 2012, 04:03:12 AM »
you can't just clear the field to clear the underlying value in the case of a file upload.
Because let's say you were just editing the record, and not re-submitting the image, you wouldn't want the image to be cleared.

So you'll need another field on the form, maybe a checkbox, that you can check when the form is saved. Ie in PreUpdate
if loc:clearPic = 1
  fil:pic = ''
end

cheers
Bruce

ianburgess

  • Full Member
  • ***
  • Posts: 119
    • View Profile
    • Email
Re: Clear photo field contents
« Reply #2 on: July 11, 2012, 05:25:29 AM »
Thanks Bruce

I tried that and it worked but I had to embed in "ValidateAll" as the "PreUpdate" was not run when saving for some reason.

Thanks

Ian

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Clear photo field contents
« Reply #3 on: July 11, 2012, 06:13:06 AM »
sorry - I meant ValidateUpdate, not PreUpdate. (Validaterecord is fine.)

cheers
Bruce