from django import forms
from django.utils.encoding import force_unicode
from django.utils.html import escape, conditional_escape
class SelectMultipleWithTitle(forms.SelectMultiple):
""" multiple select optihon with title """
def render_option(self, selected_choices, option_value, option_label):
option_value = force_unicode(option_value)
selected_html = (option_value in selected_choices) and u' selected="selected"' or ''
return u'<option value="%s"%s title="%s">%s</option>' % (
escape(option_value), selected_html,
conditional_escape(force_unicode(option_label)),
conditional_escape(force_unicode(option_label)))
相关评论
comments powered by Disqus