diff --git a/RIGS/forms.py b/RIGS/forms.py index 7bd9675b..47b0f062 100644 --- a/RIGS/forms.py +++ b/RIGS/forms.py @@ -129,6 +129,11 @@ class EventForm(forms.ModelForm): return item + def clean(self): + if self.cleaned_data.get("is_rig") and not (self.cleaned_data.get('person') or self.cleaned_data.get('organisation')): + raise forms.ValidationError('You haven\'t provided any client contact details. Please add a person or organisation.', code='contact') + return super(EventForm, self).clean() + def save(self, commit=True): m = super(EventForm, self).save(commit=False)