diff --git a/hypha/apply/determinations/forms.py b/hypha/apply/determinations/forms.py index 9a337cf291..1315c7d45c 100644 --- a/hypha/apply/determinations/forms.py +++ b/hypha/apply/determinations/forms.py @@ -520,8 +520,11 @@ def __init__( self.fields[field].disabled = True if self.draft_button_name in self.data: - for field in self.fields.values(): - field.required = False + # A determination must be set for saving a draft, + # this forces outcome to be validated. + unreq_fields = [name for name in self.fields if name != "outcome"] + for name in unreq_fields: + self.fields[name].required = False if edit: self.fields.pop("outcome") @@ -548,8 +551,8 @@ def save(self, commit=True): self.instance.outcome = int( self.cleaned_data[self.instance.determination_field.id] ) - # Need to catch KeyError as outcome field would not exist in case of edit. except KeyError: + # Need to catch KeyError as outcome field would not exist in case of edit. pass self.instance.is_draft = self.draft_button_name in self.data self.instance.form_data = self.cleaned_data["form_data"] diff --git a/hypha/apply/determinations/templates/determinations/base_determination_form.html b/hypha/apply/determinations/templates/determinations/base_determination_form.html index d575ce5492..6d59488bcc 100644 --- a/hypha/apply/determinations/templates/determinations/base_determination_form.html +++ b/hypha/apply/determinations/templates/determinations/base_determination_form.html @@ -39,7 +39,7 @@ <h2>{{ value }}</h2> {% block form_buttons %} <div class="form__group"> {% if form.draft_button_name %} - <button class="button button--submit button--white" type="submit" name="{{ form.draft_button_name }}" formnovalidate>{% trans "Save draft" %}</button> + <button class="button button--submit button--white" type="submit" name="{{ form.draft_button_name }}">{% trans "Save draft" %}</button> {% endif %} <button class="button button--submit button--primary" :disabled="isFormSubmitting" type="submit" name="submit">{% trans "Submit" %}</button> </div>