I have added some new widgets to the collection:
PasswordField
ImageField
ButtonField
RadioButton
CheckBox
RadioButtonList
CheckBoxList
In addition, I have made a couple of modifications to the SelectField:
1. The "options" parameter takes a list of tuples(value, text, attrs)
or a function that returns same.
2. The "selected" attribute is set automatically based on input
value(s).
The CheckBoxList and RadioButtonList work the same way, with the
"checked" attribute set automatically.
For example:
s = SelectField("categoryID", options=[("XML", "XML Document", {}),
("HTML", "HTML Document", {})])
If the selected option is "XML" then the output is:
<select name="categoryID">
<option value="XML" selected>XML document</option>
<option value="HTML">HTML document</option>
</select>
Alternatively:
def get_categories():
return [(cat.id, cat.name, {'onclick':"alert('%s')" %cat.name}) for
cat in
model.Category.select()]
s = SelectField("categoryID", options=get_categories)
c = CheckBoxList("categories", options=get_categories)
This is handy in situations where the options have to be generated
dynamically during template insertion for example.