| 175 | class SelectWTitle(Select): |
| 176 | def render(self, name, value, attrs=None, choices=()): |
| 177 | if value is None: value = '' |
| 178 | final_attrs = self.build_attrs(attrs, name=name) |
| 179 | output = [u'<select%s>' % flatatt(final_attrs)] |
| 180 | str_value = smart_unicode(value) # Normalize to string. |
| 181 | for option_value, option_label, option_title in chain(self.choices, choices): |
| 182 | option_value = smart_unicode(option_value) |
| 183 | selected_html = (option_value == str_value) and u' selected="selected"' or '' |
| 184 | output.append(u'<option value="%s"%s title="%s">%s</option>' % (escape(option_value), selected_html, escape(smart_unicode(option_title)), escape(smart_unicode(option_label)))) |
| 185 | output.append(u'</select>') |
| 186 | return u'\n'.join(output) |
| 187 | |