-
Notifications
You must be signed in to change notification settings - Fork 422
Open
Labels
Description
Form:
class ContactForm(ModelForm):
scope_prefix = 'contact_data'
form_name = 'contact_form'
layout = Layout(
Row('name', 'function'),
Row('primary', 'user_pwd')
)
class Meta:
model = Contact
fields = ('name', 'function','primary', 'user_pwd')
def __init__(self, *args, **kwargs):
super(ContactForm, self).__init__(*args, **kwargs)
if self.instance.pk:
self.fields["user_pwd"].disabled = True
if self.initial.get("primary"):
self.fields["primary"].disabled = True
else:
# self.fields["user_pwd"].widget = forms.HiddenInput()
self.fields["user_pwd"].widget.attrs["type"] = "hidden"
self.fields["user_pwd"].label = ""
Output:
