If f is a MultiSelectField, then when the form is submitted the type of
f.value() depends on whether none, one or more than one option was
selected.
If none was selected, f.value() is None. This makes sense and works with
the NotEmpty validator as opposed to the RequiredField validator.
But if one option was selected, f.value() is type string and is equal to
whatever was selected, whereas if more than one option was selected,
f.value() is type list, with members being strings for the options
selected.
I find this unfortunate, or at least I can't understand why this design
decision was made. Why doesn't f.value() always be a list (if not None),
and just have one element (the single string) if only one option was
selected?
Currently, since I treat the field value uniformly whether there is one
or more than one option, I have to do a "if type(f.value()) ==
type(""):" and create a single element list before processing it. (My
initial assumption that the value is always a list was a confusing
mistakeg to track down, since you can iterate over strings...)
I would rather test the length of the list if I need to know that than
the type of the return.
Please explain if this was intentionally designed this way - would it be
a bad idea for me to modify FormKit to behave as I describe?
THank you,
Steve
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Webware-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/webware-discuss