Glauco ha scritto:
> Whats the best solution for validate a RepeatingFieldSet?
>   

from turbogears.validators import Schema, ForEach, String, Int
from turbogears.widgets import WidgetsList, RepeatingFieldSet, TextField


Say you have a repetition of

class MyFormFields(WidgetsList):
    stuff = RepeatingFieldSet(
                                     fields = [
                                         TextField('first'),
                                         TextField('second')
                                         ]
                                     )


You can validate each repetition separately, with a subclass of Schema:

class RepetitionSchema(Schema):
    first = String
    second = Int(not_empty=True)

    chained_validators  = [  .... a list FormValidator instances, if 
any... ]


Then, as the main validator for the whole form:

class MyFormSchema(Schema):
    stuff = ForEach( RepetitionSchema()) )



that's all!



--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to