Em Quinta 11 Maio 2006 13:02, mulicheng escreveu:

> What I haven't found is how to make a widget form behave all the way
> like a Shema in FE.  Specifically, I'm looking for the
> chained_validators functionality (so I can apply a few validators to
> the whole form).  I see a Schema validator in the TG validators but
> haven't found an example or documentation on how to get this
> functionality.

Sorry for the lack of time...  This works:


from turbogears import validators
class UpdateRegistrationValidator(validators.Schema):
    user_id = validators.Int(not_empty = True)
    name = validators.UnicodeString(not_empty = True)
    email = validators.Email(not_empty = True)
    old_password = validators.UnicodeString(if_empty = None)
    new_password = validators.UnicodeString(if_empty = None)
    password_confirmation = validators.UnicodeString(if_empty = None)
    chained_validators = [validators.FieldsMatch('new_password', 
                                                 'password_confirmation')]



Then you specify this validator in your form:


from turbogears import widgets
update_form = widgets.TableForm(
          # ...
          validator = ValidadorAtualizarCadastro(),
          )


That's all. ;-)


Be seeing you,
-- 
Jorge Godoy      <[EMAIL PROTECTED]>


--~--~---------~--~----~------------~-------~--~----~
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