Disable the local part field when it can't be changed
authorMagnus Hagander <magnus@hagander.net>
Mon, 2 Jun 2025 13:27:33 +0000 (15:27 +0200)
committerMagnus Hagander <magnus@hagander.net>
Mon, 2 Jun 2025 13:27:33 +0000 (15:27 +0200)
ItÍ„'s silly to have a dropdown you can change and only give an error
message later :)

pgmailmgr/mailmgr/forms.py

index a3c59b7c593ba6b87bebdd48c047ac1b344d9e2a..91ee7bd7671d16f9ab456bea209f2631130ad7c1 100644 (file)
@@ -62,6 +62,9 @@ class VirtualUserForm(forms.ModelForm):
 
         self.fields['account'] = forms.CharField(max_length=200, widget=AccountEmailWidget(instance.account), required=False)
 
+        if self.instance.pk:
+            self.fields['local_domain'].disabled = True
+
     def clean_local_domain(self):
         if not self.instance.pk:
             return self.cleaned_data['local_domain']