💄 renders inputs as Bootstrap radio buttons

This commit is contained in:
Jean-Louis Jouannic 2022-07-05 21:23:49 +02:00 committed by Christopher Charbonneau Wells
parent 956125afcc
commit e86d7cc6f6
3 changed files with 11 additions and 1 deletions

View File

@ -0,0 +1,8 @@
{% with id=widget.attrs.id %}
<div{% if id %} id="{{ id }}"{% endif %} class="btn-group btn-group-toggle" data-toggle="buttons">
{% for group, options, index in widget.optgroups %}
{% for option in options %}
{% include option.template_name with widget=option %}
{% endfor %}
{% endfor %}
</div>{% endwith %}

View File

@ -2,7 +2,8 @@
{% if widget.wrap_label %}
<label{% if widget.attrs.id %}
for="{{ widget.attrs.id }}"{% endif %}>{% endif %}{% include "django/forms/widgets/input.html" %}
for="{{ widget.attrs.id }}"{% endif %}
class="btn btn-outline-light btn-no-hover">{% endif %}{% include "django/forms/widgets/input.html" %}
{% if widget.wrap_label %}
{% include "core/child_thumbnail.html" with child=widget %}
{{ widget.label }}</label>{% endif %}

View File

@ -85,6 +85,7 @@ class TagsEditor(Widget):
class ChildRadioSelect(RadioSelect):
input_type = "radio"
template_name = "core/child_radio.html"
option_template_name = "core/child_radio_option.html"
def create_option(self, name, value, label, selected, index, subindex=None, attrs=None):