diff --git a/src/newsreader/core/forms.py b/src/newsreader/core/forms.py new file mode 100644 index 0000000..ca3fe22 --- /dev/null +++ b/src/newsreader/core/forms.py @@ -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} diff --git a/src/newsreader/news/collection/forms.py b/src/newsreader/news/collection/forms.py index 604500d..c79a867 100644 --- a/src/newsreader/news/collection/forms.py +++ b/src/newsreader/news/collection/forms.py @@ -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 + ) diff --git a/src/newsreader/news/core/templates/news/core/widgets/rule.html b/src/newsreader/news/core/templates/news/core/widgets/rule.html index c8535e8..beebe29 100644 --- a/src/newsreader/news/core/templates/news/core/widgets/rule.html +++ b/src/newsreader/news/core/templates/news/core/widgets/rule.html @@ -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 %} diff --git a/src/newsreader/templates/components/form/checkbox.html b/src/newsreader/templates/components/form/checkbox.html index 42ac691..c36d5f6 100644 --- a/src/newsreader/templates/components/form/checkbox.html +++ b/src/newsreader/templates/components/form/checkbox.html @@ -1,10 +1,7 @@