The delete checkbox is present only when there is no validator or the 
validator is IS_EMPTY_OR (otherwise, it assumes a file is required and you 
are therefore not allowed to delete it). This was actually reported as a 
bug a while back, but perhaps not fixed (not sure what version you are 
using).

Anyway, why don't you put all of your validators inside IS_EMPTY_OR? 
Otherwise, if someone leaves it empty, the IS_LENGTH validator will still 
fail.

Anthony

On Sunday, February 8, 2015 at 11:22:34 AM UTC-5, Annet wrote:
>
> In a table I have th following field definition:
>
> Field('image', type='upload', 
> requires=[IS_EMPTY_OR(IS_IMAGE(extensions=('gif', 'jpg', 'jpeg', 'png'), 
> maxsize=(750, 240), error_message='Afmeting: maxWidth is 300 pixels 
> maxHeight is 240 pixels. File format: gif, jpg, jpeg, png')), 
> IS_LENGTH(64*1024, error_message='File size overschreidt 64 KB')], 
> label='Image file * ', autodelete=True)
>
>
> In a function I have the follwing code:
>
> folder = 'nodeID' + str(nodeID)
> db.prm_ad.image.uploadfolder = 
> os.path.join(request.env.applications_parent, 'applications',
>                                               'dbmodel', 'static', 
> 'uploads', folder)
>
> record = db.prm_ad(nodeID=nodeID)
> form = SQLFORM(db.prm_ad, record, deletable=True, showid=False,
>                formstyle=bootstrap3, hidden=dict(nodeID=nodeID),
>                upload=URL('dbmodel', 'static/uploads', folder, 
> args=request.vars.image))
>
> if hasattr(request.vars.image, 'filename'):
>     form.vars.imageFilename = request.vars.image.filename
>
>
> My problem is that the form does not contain a delete checkbox for the 
> image field, so
> after the user has uploaded an image, he isn't able to delete the image.
>
> The image is part of an advertisment which also contains text fields and a 
> URL field.
>
> Is there a way to solve this issue?
>
>
> Kind regards,
>
> Annet
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to