Dont't overwrite default checkbox

This caused issues in the admin
This commit is contained in:
Sonny 2020-07-26 18:33:52 +02:00
parent 2b10612304
commit c04f23b3ee
7 changed files with 18 additions and 11 deletions

View file

@ -0,0 +1,9 @@
from django import forms
class CheckboxInput(forms.CheckboxInput):
template_name = "components/form/checkbox.html"
def get_context(self, name, value, attrs):
context = super().get_context(name, value, attrs)
return {**context, **attrs}

View file

@ -5,6 +5,7 @@ from django.utils.translation import gettext_lazy as _
import pytz
from newsreader.core.forms import CheckboxInput
from newsreader.news.collection.choices import RuleTypeChoices
from newsreader.news.collection.models import CollectionRule
from newsreader.news.collection.reddit import REDDIT_API_URL
@ -95,4 +96,6 @@ class SubRedditRuleForm(CollectionRuleForm):
class OPMLImportForm(forms.Form):
file = forms.FileField(allow_empty_file=False)
skip_existing = forms.BooleanField(initial=False, required=False)
skip_existing = forms.BooleanField(
initial=False, required=False, widget=CheckboxInput
)

View file

@ -1,7 +1,7 @@
{% load filters %}
{% with option.instance|id_for_label:"category" as id_for_label %}
{% include "components/form/checkbox.html" with widget=option checked=option.selected id_for_label=id_for_label only %}
{% include "components/form/checkbox.html" with name=option.name value=option.value checked=option.selected id=id_for_label only %}
{% endwith %}
{% if option.instance.favicon %}

View file

@ -1,10 +1,7 @@
<div class="checkbox">
{% if widget %}
{% include "components/form/input.html" with widget=widget %}
{% else %}
{% include "components/form/input.html" with id=id name=name type="checkbox" value=value data_input=data_input checked=checked %}
{% endif %}
<label class="checkbox__label" for="{% if widget %}{{ widget.attrs.id }}{% else %}{{ id_for_label }}{% endif %}">
{% include "components/form/input.html" with id=id name=name type="checkbox" value=value checked=checked widget=widget %}
<label class="checkbox__label" for="{{ id }}">
<span class="checkbox__box"/>
</label>
</div>

View file

@ -3,5 +3,5 @@
type="{{ widget.type }}" name="{{ widget.name }}"
{% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %}
{% endif %}
{% include "django/forms/widgets/attrs.html" %}>
{% include "components/form/attrs.html" %}>
{% endspaceless %}

View file

@ -1 +0,0 @@
../../../components/form/attrs.html

View file

@ -1 +0,0 @@
../../../components/form/checkbox.html