Widgets
web2py provides a flexible method for applying various input and output controls to your form fields. Input controls are called widgets and output controls are called representations. Here is a sample widget taken directly from the book (7.5):
def my_string_widget(field, value):
return INPUT(_name=field.name,
_id="s_s\" field._tablename, field.name),
_class=field.type,
_value=value,
requires=field.requires)
Field('comment', 'string', widget=my_string_widget)
This makes it very easy to customize your forms in a DRY manner. The application below includes 8 ready to use widgets. Here are screenshots of a few:




Download application and enjoy! All of the widget code (excluding any required javascript, css or images) is in A_widgets.py in the models folder.
.playincard....
ross.peoples...
frank
abhishekgupt...