##// END OF EJS Templates
helpers: refactor select to build Options without temporary list...
Mads Kiilerich -
r7742:3fd3ce1d default
parent child Browse files
Show More
@@ -162,8 +162,10 b' def reset(name, value, id=NotGiven, **at'
162 162 def select(name, selected_values, options, id=NotGiven, **attrs):
163 163 """Convenient wrapper of webhelpers2 to let it accept options as a tuple list"""
164 164 if isinstance(options, list):
165 l = []
166 for x in options:
165 option_list = options
166 # Handle old style value,label lists
167 options = Options()
168 for x in option_list:
167 169 if isinstance(x, tuple) and len(x) == 2:
168 170 value, label = x
169 171 elif isinstance(x, basestring):
@@ -171,8 +173,7 b' def select(name, selected_values, option'
171 173 else:
172 174 log.error('invalid select option %r', x)
173 175 raise
174 l.append(Option(label, value))
175 options = Options(l)
176 options.add_option(label, value)
176 177 return webhelpers2_select(name, selected_values, options, id=id, **attrs)
177 178
178 179
General Comments 0
You need to be logged in to leave comments. Login now