From 00226e9c22361e57a309fbc0d730814e9dfe4403 Mon Sep 17 00:00:00 2001 From: Arona Date: Thu, 28 May 2020 21:46:16 +0100 Subject: [PATCH] FIX: Don't set every boolean input to radios --- RIGS/forms.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/RIGS/forms.py b/RIGS/forms.py index 54604d5d..5c7c553a 100644 --- a/RIGS/forms.py +++ b/RIGS/forms.py @@ -156,12 +156,16 @@ class EventAuthorisationRequestForm(forms.Form): class EventRiskAssessmentForm(forms.ModelForm): - forms.BooleanField.widget = forms.RadioSelect(choices=[ - (True, 'Yes'), - (False, 'No') - ], attrs={'class':'custom-control-input'}) - + def __init__(self, *args, **kwargs): + super(EventRiskAssessmentForm, self).__init__(*args, **kwargs) + for name, field in self.fields.items(): + if field.__class__ == forms.BooleanField: + field.widget = forms.RadioSelect(choices=[ + (True, 'Yes'), + (False, 'No') + ], attrs={'class': 'custom-control-input'}) + class Meta: model = models.RiskAssessment fields = '__all__' - exclude = ['event', 'completed_by'] + exclude = ['event']