Skip to content
This repository

Fix product form validation when the parent field is excluded #264

Merged
merged 2 commits into from over 1 year ago

2 participants

Asia Biega David Winterbottom
Asia Biega
fjern commented July 31, 2012

Some projects may want to exclude the parent field from the product update form - need to fix the form validation in this case so that they can call the super clean.

David Winterbottom codeinthehole merged commit d521b2e into from August 02, 2012
David Winterbottom codeinthehole closed this August 02, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 3 additions and 1 deletion. Show diff stats Hide diff stats

  1. 4  oscar/apps/dashboard/catalogue/forms.py
4  oscar/apps/dashboard/catalogue/forms.py
@@ -187,7 +187,9 @@ def save_attributes(self, object):
187 187
 
188 188
     def clean(self):
189 189
         data = self.cleaned_data
190  
-        if data['parent'] is None and not data['title']:
  190
+        if 'parent' not in data and not data['title']:
  191
+            raise forms.ValidationError(_("This field is required"))
  192
+        elif 'parent' in data and data['parent'] is None and not data['title']:
191 193
             raise forms.ValidationError(_("Parent products must have a title"))
192 194
         return data
193 195
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.