On Apr 5, 2007, at 9:45 AM, Max Ischenko wrote:
> Hello, > > I wonder why this test fails: > > def test_options(): > w = MultipleSelectField(options="Group1 Group2 Group3".split()) > eq_(['Group3', 'Group1'], w.validate(['Group3', 'Group1'])) > print w.validate(['GroupX']) > assert 0, "formencode.Invalid not raised" > > I was assuming that the select widget will only accept options that > are in the options list. No? This is a tricky case. For that test to pass a OneOf valiadator is needed, however, that would break the callable support for the "options" parameter since the validator is fixed at construction time. I can think of 2 ways to solve it: 1) avoid using a callable for "options" and pass a OneOf validator explicitly 2) Use a hidden field to store view state and make validators aware of it to validate accordingly. 2 is probably the best option in the long-run but the hardest to design/implement. It would also allow disabling fields dynamically which is now not possible for required fields since validation would fail. Ideas? Alberto P.S: Cross-posting to toscawidgets-discuss --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears Trunk" group. To post to this group, send email to turbogears-trunk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears-trunk?hl=en -~----------~----~----~----~------~----~------~--~---