Skip to content

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

Disallow changing category's 'hidden' field value if its parent is hidden

Marcin Gębalacda10685b926
diff --git a/saleor/dashboard/category/forms.py b/saleor/dashboard/category/forms.py
index 689feb9211..b68575e287 100644
--- a/saleor/dashboard/category/forms.py
+++ b/saleor/dashboard/category/forms.py
@@ -11,6 +11,11 @@ class CategoryForm(forms.ModelForm):
parent = TreeNodeChoiceField(queryset=Category.objects.all(),
required=False)
+ def __init__(self, *args, **kwargs):
+ super(CategoryForm, self).__init__(*args, **kwargs)
+ if self.instance.parent and self.instance.parent.hidden:
+ self.fields['hidden'].widget.attrs['disabled'] = True
+
class Meta:
model = Category
exclude = ['slug']