Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add field error instead of non-field

oldPadavan766d475943d0
diff --git a/saleor/dashboard/collection/forms.py b/saleor/dashboard/collection/forms.py
index be0bf3da01..88dc5b1c5f 100644
--- a/saleor/dashboard/collection/forms.py
+++ b/saleor/dashboard/collection/forms.py
@@ -50,8 +50,7 @@ class AssignHomepageCollectionForm(forms.ModelForm):
cleaned_data = super().clean()
homepage_collection = cleaned_data['homepage_collection']
if homepage_collection and not homepage_collection.is_published:
- raise forms.ValidationError(
- pgettext_lazy(
- 'Homepage collection assign form error',
- 'Selected collection is not published'))
+ self.add_error('homepage_collection', pgettext_lazy(
+ 'Homepage collection assign form error',
+ 'Selected collection is not published'))
return cleaned_data