diff options
Diffstat (limited to 'ishtar_common/widgets.py')
-rw-r--r-- | ishtar_common/widgets.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index ec3f8b011..2df06cf21 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -260,6 +260,20 @@ class DeleteWidget(forms.CheckboxInput): return mark_safe(output) +class SwitchWidget(forms.CheckboxInput): + def render(self, name, value, attrs=None, renderer=None): + attrs = self.build_attrs( + attrs, {"name": name, "value": '0', + 'class': "switch", + 'type': 'checkbox'} + ) + final_attrs = flatatt(attrs) + output = u"""<span class="switch"> + <input{}> +</span>""".format(final_attrs, attrs['id']) + return mark_safe(output) + + class ImageFileInput(ClearableFileInput): template_name = 'widgets/image_input.html' NO_FORM_CONTROL = True |