I have made a workarround.
if (request.args[1] == 'edit'):
#obtenemos el id del campo a modificar
idUpdate = request.args[3]
El lunes, 20 de marzo de 2017, 10:40:23 (UTC-3), Santiago Cartasegna
escribió:
>
> Hello,
>
> I am trying to do some validation before updating a record. My idea is to
> verify that the new value of a field is bigger than the old one.
>
> However I am not getting how to do it:
>
>
> table definition:
>
>
> db.define_table('t_myTable',
> Field('f_year', type='integer',
> label=T('Año')),
> Field('f_quantity', type='integer',
> label=T('cantidad')),
> Field('f_user', type='reference auth_user',
> label=T('Cargo'),default=auth.user_id,writable=False),
> auth.signature,
> format='%(f_year)s',
> migrate=settings.migrate)
>
>
> On my controller:
>
>
> # -*- coding: utf-8 -*-
> @auth.requires_login()
> def viewTable():
> form = SQLFORM.smartgrid(db.t_myTable,onupdate=auth.archive,deletable=
> False,csv=False,details=False,searchable=False
> ,onvalidation=is_bigger)
> return locals()
>
>
> def is_bigger(form):
> idUpdate = request.args(3).first
> r = db(db.t_myTable.f_quantity==idUpdate.id).select()
> if r.f_quantity < form.vars.f_quantity:
> form.errors.f_quantity = 'Some error message ' % (r.f_quantity)
>
>
> I am not getting the way of get the OLD row value before update
>
--
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.