On Jan 7, 2007, at 6:09 PM, remi jolin wrote:
I have something like
class MyFields(widgets.WidgetsList):
f1 = widgets.TextField('f1')
f2 = widgets.TextField('f2')
f3 = widgets.TextField('f3')
class MySchema(validators.Schema):
f1 = validators.UnicodeString(not_empty=True)
f2 = validators.UnicodeString(not_empty=True) f3 =
validators.UnicodeString(not_empty=True)
form = widgets.TableForm(fields=MyFields(), validator=MySchema())
Class Root(controllers.RootController):
...
@expose('.templates.my_template')
@validate(form=form)
@error_handler()
def display_form(self, **kw)
return dict(form=form, disabled_fields=['f2'])
When I call /display_form, I get the expected form with only f1 and
f3. But on validation, despite f2 is disabled, it goes through the
validation process which of course, fails.
What did I miss ? (Bug or feature ??)
Bug. However, this isn't easy to fix because the validator for the
whole form is created when the form is initialized. This means that
it's not aware of anything that changes in the form when it's
displayed so there's not much you can do about this with the current
state of affairs.
A way to fix this could be a custom Schema subclass that looked into
a hidden field with information about which fields are disabled. The
form should populate (and encrypt!) that hidden field when it's
displayed so the validator can skip validation on those fields that
are disabled.
However, this doesn't look very pretty to me so any other ideas are
welcomed... :)
Alberto
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---