Friday, May 11, 2007

Extensible CheckBox List

Introducing a brand-new widget for TurboGears: Extensible CheckBox List!

To use it:
  1. easy_install xcbl
  2. In your,
    from xcbl.widgets import ExtensibleCheckBoxList
  3. In your form's WidgetsList,
    pets = ExtensibleCheckBoxList(options=['cats','dogs','turtles'])
    (exactly the same as you would for an ordinary CheckBox List widget)
The result - a CheckBox List with an "other" field that lets the user hand-enter new options - as many as they want.

Unfortunately, the new items will appear beneath the "Other:" box, not above it, unless you upgrade your MochiKit to 1.4. Details on how to do that and more are here.

Developing it was lots of fun - it really shows how easily a relative amateur can contribute to TurboGears. I hope to write up a "Developing and Contributing TurboGears Widgets for Dummies" document soon, based on the experience.

No comments: