4 new widgets; attrs now supported

Widget #1: Hidden

This is simply a hidden input field, but it is placed outside the
table when using widget.TableForm.

Widget #2: TextArea

A textarea field. Yep.

Widget #3: FileField

Thanks to danjac40, there is now a simple widget for allowing file uploads.

Widget #4: SelectField

This is either a dropdown or a multiple-select box. You can choose
either by using the new "attrs" parameter.

Note: You may use a list as default parameters for the SelectField.
This allows for multiple select fields to have multiple values
selected by default. *phew*

The "attrs" parameter takes a dictionary and literally throws it into
a kid "py:attrs" attribute. It's really quite simple. The following
example shows a simple quickstarted app showcasing these new features:

options_a = [
             {"value":"val1", "text":"Choose me!"},
             {"value":"val2", "text":"NO! Choose me!"}
            ]

options_b = [
             {"value":"val3", "text":"Choose me!"},
             {"value":"val4", "text":"Choose me as well!"}
            ]

form = widgets.TableForm(widgets=[
         widgets.Hidden("my_hidden_field", default="hidden value"),
         widgets.TextArea("my_text_area", default="text value"),

         # Standard dropdown form
         widgets.SelectField(options=options_a,
                             name="DropDown",
                             default="val1"),

         # Multiple selection
         widgets.SelectField(options=options_b,
                             attrs={"multiple":"True"},
                             name="Multiple",
                             default=["val3","val4"])
         ])

"attrs" is supported in the following widgets:
  TextField
  TextArea
  SelectField
  SubmitButton

That's it for now, mainly because some of the others (TableForm,
CalendarDatePicker, etc.) will be much more complicated to implement.
For example, in TableForm we'll want to support alternating colors.

Thoughts and feedback are greatly appreciated. Criticism is loathed
but necessary. Praise is probably not good for my ego ;)


--
[EMAIL PROTECTED]

Reply via email to