mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 03:31:04 +01:00
make password a required field when restriction_type = password
This commit is contained in:
parent
0fbd3e7e14
commit
47c0a197c8
@ -83,3 +83,12 @@ class PageViewRestrictionForm(forms.Form):
|
||||
('password', ugettext_lazy("This page is only viewable to users who enter this password:")),
|
||||
], widget=forms.RadioSelect)
|
||||
password = forms.CharField(required=False)
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super(PageViewRestrictionForm, self).clean()
|
||||
|
||||
if cleaned_data.get('restriction_type') == 'password' and not cleaned_data.get('password'):
|
||||
self._errors["password"] = self.error_class([_('This field is required.')])
|
||||
del cleaned_data['password']
|
||||
|
||||
return cleaned_data
|
||||
|
Loading…
Reference in New Issue
Block a user