SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 66655a31 authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Update widgets

parent 27893672
No related branches found
No related tags found
No related merge requests found
{% with id=widget.attrs.id %}
{% for group, options, index in widget.optgroups %}
{% for option in options %}
{% include 'widgets/checkbox_option_as_btn.html' with widget=option %}
{% endfor %}
{% endfor %}
{% endwith %}
{% include "django/forms/widgets/input.html" %}
<label{% if widget.attrs.id %} class="btn btn-info" for="{{ widget.attrs.id }}"{% endif %}>
{{ widget.label }}</label>
from django import template
from ..widgets import SelectButtonWidget
register = template.Library()
@register.filter
def checkboxes_as_btn(field):
w = field.field.widget
return field.as_widget(SelectButtonWidget(attrs=w.attrs, choices=w.choices))
from django.forms.widgets import CheckboxSelectMultiple
class SelectButtonWidget(CheckboxSelectMultiple):
template_name = 'widgets/checkbox_as_btn.html'
{% extends 'scipost/base.html' %}
{% load bootstrap %}
{# {% load highlight %}#}
{% load extra_form_widgets %}
{% block pagetitle %}: list{% endblock pagetitle %}
......@@ -22,13 +22,7 @@
<label>Type</label>
</div>
<div class="form-group checkboxes auto-submit">
{% for field in form.models %}
<input type="checkbox" name="{{field.name}}" id="{{field.id_for_label}}" value="{{field.choice_value|stringformat:'s'}}" {% if field.choice_value in form.models.value %}checked="checked"{% endif %}>
<label class="btn btn-info" for="{{field.id_for_label}}">
{{field.choice_label}}
</label>
{% endfor %}
{{form.models|checkboxes_as_btn}}
</div>
<label>Date from</label>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment