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)))
Django multiple select option with title
关于作者
热爱开源与分享。主要从事混合云、数据库 SaaS 等运维开发与相关团队管理工作。
评论
评论使用 GitHub Discussions 承载;留言需要 GitHub 账号。