Some of the information here may be outdated, please check the book instead

Since version trunk 288 you can create dummy databases with SQLDB(None) and they can be used to generate form. Here is how.

Define the following helper function:

 def form_factory(*a): return SQLFORM(SQLDB(None).define_table(*a))

and now you can create a controller like the following

 def index():
     if form.accepts(request.vars,session):
         response.flash='form accepted'
         ### do something with form.vars, perhaps redirect somewhere else
     elif form.errors:
         response.flash='errors in form'
         response.flash='please fill the form'
     return dict(form=form)

the form object, returned by form factory, behaves like a SQLFORM except that there is no insert because there is no DB. Notice that the image has been stored in a temporary file under uploads and its new name is in form.vars.image_newfilename

© 2008-2010 by Massimo Di Pierro - All rights reserved - Powered by web2py - design derived from a theme by the earlybird
The content of this book is released under the Artistic License 2.0 - Modified content cannot be reproduced.