W-Mark Kubacki schrieb: > > [...] > I cannot figure out how to display error messages in a Form which gets > validated by Schema. > > I have separated the entirety in a Form, WidgetsList and Schema. The > Form itself utilizies field_for(), error_for() and so on. > [Two examples.; Anm. Mark] > > What must one do to modify the second example to behave like the first > still using a Schema? [...]
Okay, I figured it out. Although the form has no widgets in it with
validators, one must pass it to a @tg.validate to have its
"self.is_validated" be set to True. [see 1 for effect]
That should really be mentioned in documentation. [2]
So, here is the full (working) example:
@tg.expose(...)
def index(self):
return dict(form=myform)
@tg.expose(...)
@tg.error_handler(index)
@tg.validate(form=myform) # has no validators
@tg.validate(validators=MyFormValidationSchema()) # now works
def new(self, **kwargs)
...
-- Mark
[1] turbogears/widgets/forms.py line 279 in 'def error_for(...'
[2] http://docs.turbogears.org/1.0/ValidateDecorator#schema-validation
smime.p7s
Description: S/MIME Cryptographic Signature

