[web2py] Re: convert field to multiple view values?

2010-06-05 Thread mdipierro
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

[web2py] Re: convert field to multiple view values?

2010-06-05 Thread Iceberg
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

[web2py] Re: convert field to multiple view values?

2010-06-05 Thread MikeEllis
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

[web2py] Re: convert field to multiple view values?

2010-06-05 Thread MikeEllis
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 =