From 111b0ec4fb53fdb1ab3625ce6bea201730ae83d9 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 10 Dec 2018 15:26:53 +0100 Subject: [PATCH] =?UTF-8?q?core:=20make=20SignUpForm=E2=80=99s=20fields=20?= =?UTF-8?q?readonly=20if=20there=20is=20an=20initial=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- passbook/core/forms/authentication.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/passbook/core/forms/authentication.py b/passbook/core/forms/authentication.py index 89b7520a0..658e97b05 100644 --- a/passbook/core/forms/authentication.py +++ b/passbook/core/forms/authentication.py @@ -50,6 +50,10 @@ class SignUpForm(forms.Form): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + # All fields which have initial data supplied are set to read only + if 'initial' in kwargs: + for field, _ in kwargs.get('initial').items(): + self.fields[field].widget.attrs['readonly'] = 'readonly' # TODO: Dynamically add captcha here # if not Setting.get_bool('recaptcha:enabled'): # self.fields.pop('captcha')