BTW this is actually a separate issue. If the dict data_new misses any
of the fields you get the same KeyError; it should be the case that any
missing values are set to None or default.

Another point: to set the values of "cidade", "estado" and "cep", you
have to do this:

dict_new = dict(
    widget = dict(
      cidade="Rio de Janeiro",
      estado=None,
      cep=None),...

(Does cidade mean city ? My Portuguese is almost non-existent ;-))

This is obviously inconvenient if you are passing in a SQLObject
instance, for example, as you have to break it down for each field set.

Perhaps instead of a field set widget we could have a separate FieldSet
class. For example:

my_form = TableForm(
      widgets = [TextField("name"),
      TextField("country"),
       TextField("postcode"),
        TextField("street")],
       fieldsets = [FieldSet("address"), widgets = ["country",
"postcode", "street"]))

The FieldSet class merely handles layout; it does not do any error or
other form handling and is not a Widget subclass. It has an optional
template parameter. You can pass in a widget list and optionally a
fieldset list, if you want to have nested fieldsets. When the form is
rendered it renders the fieldsets somehow in the correct order.

This FieldSet class would allow you to create complex form layouts but
keep the form handling simple.

Reply via email to