there is a typo :  form = SQLFORM( t_templates, record)  should be  form =
SQLFORM( db.t_templates, record)

On Tue, May 1, 2012 at 12:13 PM, Khalil KHAMLICHI <
[email protected]> wrote:

> this might not be the perfect solution but it might let you move on
>
> models :
> db.define_table('t_templates',
>       Field('f_template', type='upload', label=T('File'),notnull=True),
>
>
>       Field('f_revision', type='integer', label=T('Revision'),
>           default=1,
>          * writable=False, #hide it on the form*
>           ),
>       )
>
> Controller:
> def edit():
>       ID = request.vars.id
>       record = db(db.t_templates.Id == ID).select()[0]
>       form = SQLFORM( t_templates, record)
>       def mycustom(form):
>            form.vars.t_revision = int(form.vars.t_revision) + 1
>       # we call our function upon validation
>       if form.process(onvalidation={'onsuccess':mycustom}).accepted:
>            pass
>       return dict(form=form)
>
> On Tue,
> May 1, 2012 at 11:31 AM, François Delpierre 
> <[email protected]>wrote:
>
>> Hi,
>>
>> Here is exactly what I would like to have, but it does not compute on
>> update :
>>
>> db.define_table('t_templates',
>>       Field('f_template', type='upload', label=T('File'),notnull=True),
>>
>>       Field('f_revision', type='integer', label=T('Revision'),
>>           default=1,
>>           compute=lambda row: row['f_revision']+1 ,
>>           ),
>>       )
>>
>>
>

Reply via email to