So extending your form a little....

class MyFieldSet(FieldSet):
   fields=[
            TextField("foo", validator=Int(not_empty=True)),
            TextField("bar") ]

class MySchema(Schema):
   chained_validators = [ validators.RequireIfMissing ( required='data2', missing='require2' ) ]
 
class MyForm(Form):
       fields = [
        TextName("name"),
        MyFieldSet("data1"),
        CheckBox ( "require2" ),
        MyFieldSet("data2") ]
       validator = MySchema()

The part I'm not too sure if it can be completed is how to not require any of the fields in data2 if the require2 field is not checked.  Should the above example work?  It isn't working for me but I'm not sure if it's something I've mistyped or done wrong, or if it just isn't possible with the framework.

It would be nice to have that re-use, but I'll probably just duplicate the second part of the form and then use the RequireIfMissing on each of the fields in the 2nd part.  (There are only 5 or so fields).  Now if the form had two parts each with 50 or so inputs... it would be quite painful to not have the above example work.

-Dennis

-Dennis


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to