This is a three step process:
1) disable JS validation as float for this field
form.element('input[name=height]')['_class']='feet'
2) create a custom validator that filters data in and formats data out
class FEET:
def __init__(self,error_message='invalid'):
self.error_message=error_message
And in the controller/view, you can use db.foo.height.represent =
lambda v: 'xx feet yy inch zz fraction' to display it, therefore you
need not depend on javascript.
On Jun6, 7:12am, MikeEllis wrote:
> Oops hit send by accident.
>
> so after the form.accepts(request.vars, session), you'll need co
Oops hit send by accident.
so after the form.accepts(request.vars, session), you'll need code to
convert the feet, inches, and fractions to a double and stuff it into
the database. Some of the more experienced web2py users may have a
better way, but this approach is working for me.
Cheers,
Mike
I've been using SQLFORM.factory() for cases where what's in the db
needs to be presented to the user in a different format. The online
book has some good examples. For your case, my first thought would be
to define a function in the model that generates the form, e.g.
def fooform():
fields =
4 matches
Mail list logo