Issue
How do I make a foreign key field in a form read only but still allow this field to be recognized as valid once the form is submitted? According to W3C, disabled fields are left out once the form is submitted....using the code below, I can set the field as disabled, thus readonly, but my form doesn't go through
def __init__(self, *args, **kwargs):
super(IssuesForm, self).__init__(*args, **kwargs)
self.fields['vehicle'].widget.attrs['readonly'] = True
Ideas....?
Solution
I don't know the Django or Python syntax, however, an input field of type="hidden" might be what you're looking for. If you wanted to still display the value using a disabled field, you could do that too, and rely on the hidden field for the actual value.
Answered By - Terry G Lorber
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.