It took me a while to isolate the problem. Here is a simple code to
reproduce it:
def index():
db.define_table('thing',Field('image','upload',requires=IS_NOT_EMPTY()))
db.thing.image.default = 'xxx.png'
form = SQLFORM.factory(db.thing,upload=URL('download')).process()
return locals()
It is a bin can of worms and I opened a ticket about this. For now I will
just say that giving a default to an upload field is not a good idea. You
can try do the following:
def index():
db.define_table('thing',Field('image','upload',requires=IS_NOT_EMPTY()))
form = SQLFORM.factory(db.thing,upload=URL('download')).process()
db.thing.image.default = 'xxx.png'
if form.errors['image'] == '':
del form.errors['image']
insert 'xxx.png' where needed
return locals()
On Sunday, 7 April 2013 06:54:41 UTC-5, Ramos wrote:
>
> Can you check again Massimo in the app i posted? controller default -
> Action trabalhador
>
> Thank you
>
> António
>
>
> 2013/4/6 António Ramos <[email protected] <javascript:>>
>
>> Sorry i meant trabalhador
>>
>> Action trabalhador
>> Thank you
>> No dia 06/04/2013 17:31, "Massimo Di Pierro"
>> <[email protected]<javascript:>>
>> escreveu:
>>
>> Sorry I cannot find action "empreiteiro"
>>>
>>> On Friday, 5 April 2013 16:45:39 UTC-5, Ramos wrote:
>>>>
>>>> I post here my app.
>>>>
>>>> Sorry about the quality of my code. I´m learning as i go along the way.
>>>>
>>>> The problem is in controller default, action empreiteiro
>>>>
>>>> The upload field is required but when i edit a record i see the link to
>>>> the uploaded file and if i do nothing and just save it complains that i
>>>> have to upload a file.
>>>> It is there!!
>>>>
>>>> Thank you
>>>>
>>>> António
>>>>
>>>>
>>>>
>>>> 2013/4/5 Massimo Di Pierro <[email protected]>
>>>>
>>>>> Can you post a simpler example (including mode) to reproduce the
>>>>> problem? Looks like the field in the table has a validator which requires
>>>>> an upload.
>>>>>
>>>>>
>>>>> On Friday, 5 April 2013 11:06:52 UTC-5, Ramos wrote:
>>>>>>
>>>>>> hello, i´m using a sqlform.factory to edit a record.
>>>>>>
>>>>>> The form is prepopulated using this code
>>>>>>
>>>>>>
>>>>>> row=db((db.trabalhador.id==**req**uest.args(0))).select().**first(**)
>>>>>>
>>>>>> if row:
>>>>>> for field in row:
>>>>>> if field in db.trabalhador.fields:
>>>>>>
>>>>>> print "setting -",row[field] ," on ",field
>>>>>> db.trabalhador[field].default=****row[field]
>>>>>>
>>>>>>
>>>>>> one of the fields is a required upload field.
>>>>>>
>>>>>> The rest of the code
>>>>>> form=SQLFORM.factory(db.**trabal**hador,db.t_docs,
>>>>>> submit_button="Gravar",
>>>>>> fields=['nome','bi','ncart','**n**
>>>>>> cartval','rfid','apt_medica',**'**apt_medicaval','val_formacao'**,**
>>>>>> 'f_doc'],
>>>>>> table_name='trabalhador',
>>>>>> upload=URL('download')
>>>>>> )
>>>>>> empresa=request.vars['id'] or empresa
>>>>>> extra_but = TR(DIV(A(I(_name='but',_class=****'icon-camera
>>>>>> icon-white'),' Tirar foto',_class="btn btn-primary",_id ="but")))
>>>>>> extra_fp_url = TR(DIV(INPUT(_name='fp_url',_**t**
>>>>>> ype='hidden',_id='fpurl')))
>>>>>> extra_Aptidao = TR(DIV(A(I(_name='but',_class=****'icon-file
>>>>>> icon-white'),' ',_class="btn btn-primary"),_onclick="**locati**
>>>>>> on.href='"+URL(f='**download', args=form.vars.apt_medica)+"'"****))
>>>>>> form[0].insert(-4,extra_**Aptida**o)
>>>>>> form[0].insert(-1,extra_but)
>>>>>> form[0].insert(-1,extra_fp_**url**)
>>>>>>
>>>>>> if form.process().accepted:
>>>>>> print "accepted form to save or update"
>>>>>> print form.vars
>>>>>>
>>>>>>
>>>>>>
>>>>>> When i edit a record i see the upload file. But if i do not change
>>>>>> the upload and save the record i get the error asking me to add the
>>>>>> upload
>>>>>> file.
>>>>>>
>>>>>> I need some help on this.
>>>>>> Thank you
>>>>>>
>>>>> --
>>>>>
>>>>> ---
>>>>> 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 web2py+un...@**googlegroups.com.
>>>>> For more options, visit
>>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>>> .
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>
>>> ---
>>> 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] <javascript:>.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>
--
---
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/groups/opt_out.