Wednesday, June 24, 2020

Re: Form theory - locking a field


On Wed, Jun 24, 2020, 8:06 PM Clive Bruton <clive@indx.co.uk> wrote:
I have a form in which, after filing, I would like one field to be 
locked for editing, the forms.py looks like this:

**************

class ProfileForm(forms.ModelForm):
     status = forms.ChoiceField(choices=Profile.status_choices, 
widget=forms.RadioSelect)

     class Meta:
         model = Profile
         fields = (
             'status', 'phone', 'display_phone', 'display_address', 
'display_email', 'display_loginoverride'
         )
         widgets = {
             'phone': PhoneWidget
         }

**************


While the user will be able to come back and change the other 
information on the form, I want to be able to lock the "status" 
field, so that it just shows the input they selected, not the radio 
buttons and is no longer editable by the user.

Is there a way to do this in forms.py, or would I have to construct 
the logic in a template (or perhaps some other way)?

Thanks


-- Clive

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7A4BCC9C-172C-4511-A422-6E832A72E11D%40indx.co.uk.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMKMUjv8D5_%2BFU_4UGeS3sZRMEM8j4M7d%3Da%3DKRKi6u-rs3fKwg%40mail.gmail.com.

No comments:

Post a Comment