-
Notifications
You must be signed in to change notification settings - Fork 28
Description
I can't even begin to imagine what this thing is supposed to be doing, but what it's actually doing is destroying long <select> lists.
Here's the code for the function:
def _sanitize_select_options(options):
if isinstance(options, (list, tuple)):
if _only_contains_leaves(options) and len(options) >= 2:
return (options[1], options[0])
else:
return [_sanitize_select_options(option) for option in options]
return options
Notice that if the options variable is a list of length >= 2, with elements which are not also lists (e.g. a list of several strings), it converts options into (options[1], options[0]).
Why in the world does it do this? This results in every list of 2+ options being incorrectly rendered into a <select>.
I'm no expert when it comes to recursive functions, but it appears that (besides destroying every option list) this function doesn't do anything. When I made what appeared to be the most sensible fix the remove the bug, I realized that the function stopped having any effect.
I'd suggest either removing _sanitize_select_options(), or re-writing it to do what it was originally intended to do, whatever that was. Until that time, though, FormAlchemy v1.4.3 is completely worthless. I was forced to downgrade to v1.4.2.