-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathchoice_field.py
More file actions
35 lines (28 loc) · 810 Bytes
/
choice_field.py
File metadata and controls
35 lines (28 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from django import forms
from django.forms import widgets
from .bound_choice_field import BoundChoiceField
class ChoiceField(forms.ChoiceField):
"""
A ChoiceField that renders using NHS.UK design system radios/select
components.
"""
widget = widgets.RadioSelect
bound_field_class = BoundChoiceField
def __init__(
self,
*args,
hint=None,
label_classes=None,
classes=None,
**kwargs,
):
kwargs["template_name"] = ChoiceField._template_name(
kwargs.get("widget", self.widget)
)
self.hint = hint
self.classes = classes
self.label_classes = label_classes
super().__init__(*args, **kwargs)
@staticmethod
def _template_name(widget):
return "radios.jinja"