My mistake... this is a little more complex than I thought because it
depends on the workflow. There are two options:

1) if the user does not set an image you get a default one

assuming :
db.define_table('mytable', Field('picture','upload'))
and assuming:
form=crud.create(db.mytable)

you can do:

def addimage(form):
    if not form.vars.picture:
         form.vars.picture=db.mytable.picture.store(open('path/
pic.jpg','rb'))

form=crud.create(db.mytable,
  onvalidation=lambda form:addimage(form))

This should work.

2) you want to show the user the default hence you must create a dummy
record and always use crud update instead of crud create. This is more
complex.

Massimo


On Nov 6, 2:41 am, mdipierro <[email protected]> wrote:
> This should do it.
>
> db.define_table('mytable', Field('picture','upload'))
>
> db.mytable.picture.default=lambda:db.mytable.picture.store(open('path/
> pic.jpg','rb'))
>
> On Nov 6, 1:32 am, CesarBustios <[email protected]> wrote:
>
> > Hi, please in my database i have an 'upload' type Field and i want to
> > make some picture ('pic.jpg') the default picture when the form load,
> > how can i do that???
>
> > I really hope you can help me out, Thank you!
>
>

Reply via email to