diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-04-16 18:48:59 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-06-12 08:39:42 +0200 |
commit | d5ee13b0f01871ec93a37bf12242e88e4be26af9 (patch) | |
tree | 8395900adea9628c7d077d505f212a5c99265b63 /ishtar_common | |
parent | 3d69c38a085de81e95bf5d92d0b33987de065452 (diff) | |
download | Ishtar-d5ee13b0f01871ec93a37bf12242e88e4be26af9.tar.bz2 Ishtar-d5ee13b0f01871ec93a37bf12242e88e4be26af9.zip |
Widgets: add a switch
Diffstat (limited to 'ishtar_common')
-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 |