How to make a foreign key field in a form read-only, but still allow this field to be valid after the form is submitted? According to the W3C, disabled fields are not taken into account after submitting the form ... using the code below, I can set the field as disabled, this way is read-only, but my form does not go through
def __init__(self, *args, **kwargs):
super(IssuesForm, self).__init__(*args, **kwargs)
self.fields['vehicle'].widget.attrs['readonly'] = True
Ideas ....?
Stephen
source
share