>
>  I have looked in the gluon/validators.py but I have not been able to 
> follow how the form object is used to process the returned variables. I got 
> as far as seeing a traverse method being called but didn't see how that 
> called the individual validation methods.


The HTML form helpers (i.e., INPUT, SELECT, etc.) all take a "requires" 
attribute, so what happens is that the "requires" attribute from the Field 
object gets copied to the "requires" attribute of the helper. When the form 
is traversed for validation, the helpers are able to validate their own 
values.

For example, notice the StringWidget calls the ._attributes() class method: 
https://code.google.com/p/web2py/source/browse/gluon/sqlhtml.py#148. That 
method returns a dictionary of attributes from the Field object, including 
the "requires" attribute: 
https://code.google.com/p/web2py/source/browse/gluon/sqlhtml.py#103. Those 
attributes are then included in the INPUT() helper returned by the widget.
 

> Also, is it possible to override the widget methods in SQLFORM rather than 
> define custom widgets and have to then assign these widgets to every field 
> in the models?


I think you should be able to do:

SQLFORM.widgets.string =  [your custom widget]

SQLFORM.widgets is a class attribute holding a Storage object.

Anthony

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to