Home | Trees | Indices | Help |
|
---|
|
object --+ | XmlComponent --+ | DIV --+ | FORM
Examples:
>>> from validators import IS_NOT_EMPTY >>> form=FORM(INPUT(_name="test", requires=IS_NOT_EMPTY())) >>> form.xml() '<form action="#" enctype="multipart/form-data" method="post"><input name="test" type="text" /></form>'
a FORM is container for INPUT, TEXTAREA, SELECT and other helpers
form has one important method:
form.accepts(request.vars, session)
if form is accepted (and all validators pass) form.vars contains the accepted vars, otherwise form.errors contains the errors. in case of errors the form is modified to present the errors to the user.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from Inherited from |
|
|||
|
|
|||
REDIRECT_JS =
|
|||
tag =
|
|||
Inherited from |
|
|||
Inherited from |
|
Args: components: any components that should be nested in this element attributes: any attributes you want to give to this element Raises: SyntaxError: when a stand alone tag receives components
|
Handling of attributes (normally the ones not prefixed with '_'). Nothing to postprocess yet. May be overridden by subclasses
|
EXPERIMENTAL Sanitize is naive. It should catch any unsafe value for client retrieval. |
Perform the .validate() method but returns the form Usage in controllers: # directly on return def action(): #some code here return dict(form=FORM(...).process(...)) You can use it with FORM, SQLFORM or FORM based plugins: # response.flash messages def action(): form = SQLFORM(db.table).process(message_onsuccess='Sucess!') return dict(form=form) # callback function # callback receives True or False as first arg, and a list of args. def my_callback(status, msg): response.flash = "Success! "+msg if status else "Errors occured" # after argument can be 'flash' to response.flash messages # or a function name to use as callback or None to do nothing. def action(): return dict(form=SQLFORM(db.table).process(onsuccess=my_callback) |
This function validates the form, you can use it instead of directly form.accepts. Usage: In controller:: def action(): form=FORM(INPUT(_name="test", requires=IS_NOT_EMPTY())) form.validate() #you can pass some args here - see below return dict(form=form) This can receive a bunch of arguments onsuccess = 'flash' - will show message_onsuccess in response.flash None - will do nothing can be a function (lambda form: pass) onfailure = 'flash' - will show message_onfailure in response.flash None - will do nothing can be a function (lambda form: pass) onchange = 'flash' - will show message_onchange in response.flash None - will do nothing can be a function (lambda form: pass) message_onsuccess message_onfailure message_onchange next = where to redirect in case of success any other kwargs will be passed for form.accepts(...) |
generates the xml for this component.
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Mar 16 02:36:14 2014 | http://epydoc.sourceforge.net |