0001-create-template-for-CheckboxesWidget-23413.patch
wcs/qommon/form.py | ||
---|---|---|
1109 | 1109 |
def has_error(self, request=None): |
1110 | 1110 |
return Widget.has_error(self, request=request) |
1111 | 1111 | |
1112 |
def render_content(self): |
|
1113 |
r = TemplateIO(html=True) |
|
1114 |
if self.inline: |
|
1115 |
r += htmltext('<ul class="inline">') |
|
1116 |
else: |
|
1117 |
r += htmltext('<ul>') |
|
1118 |
for widget in self.get_widgets(): |
|
1119 |
if widget.attrs and 'disabled' in widget.attrs: |
|
1120 |
r += htmltext('<li class="disabled"><label>') |
|
1121 |
else: |
|
1122 |
r += htmltext('<li><label>') |
|
1123 |
if self.readonly: |
|
1124 |
widget.attrs['disabled'] = 'disabled' |
|
1125 |
if widget.value: |
|
1126 |
r += htmltext('<input type="hidden" name="%s" value="yes" >') % widget.name |
|
1127 |
widget.name = widget.name + 'xx' |
|
1128 |
r += widget.render_content() |
|
1129 |
r += htmltext('<span>%s</span>') % widget.title |
|
1130 |
r += htmltext('</label>') |
|
1131 |
r += htmltext('</li>') |
|
1132 |
r += htmltext('</ul>') |
|
1133 |
return r.getvalue() |
|
1134 | 1112 | |
1135 | 1113 |
class ValidatedStringWidget(StringWidget): |
1136 | 1114 |
'''StringWidget which checks the value entered is correct according to a regex''' |
wcs/qommon/templates/qommon/forms/widgets/checkboxes.html | ||
---|---|---|
1 |
{% extends "qommon/forms/widget.html" %} |
|
2 |
{% block widget-control %} |
|
3 |
<ul {% if widget.inline %}class="inline"{% endif %}> |
|
4 |
{% for w in widget.get_widgets %} |
|
5 |
<li {% if "disabled" in w.attrs %}class="disabled"{% endif %}> |
|
6 |
<label> |
|
7 |
{% if widget.readonly or "disabled" in w.attrs %} |
|
8 |
<input type="hidden" name="{{w.name}}" value="yes" > |
|
9 |
{% endif %} |
|
10 |
<input name="{{w.name}}{% if widget.readonly %}xx{% endif %}" |
|
11 |
type="checkbox" |
|
12 |
{% if widget.readonly or "disabled" in w.attrs %}disabled{% endif %} |
|
13 |
{% if w.value %}checked{% endif %} |
|
14 |
><span>{{ w.title }}</span></label> |
|
15 |
</li> |
|
16 |
{% endfor %} |
|
17 |
</ul> |
|
18 |
{% endblock %} |
|
0 |
- |