Running Django v1.1.1 on Apache v2.2.8 with Firefox v3.5.4.
I have a very simplified and unreal example below to demonstrate what's
happening.
class MyForm(forms.Form):
string1 = forms.CharField()
string2 = forms.CharField(widget = forms.HiddenInput())
def clean(self):
cleaned = self.cleaned_data
if not cleaned.has_key("string2") and
cleaned.has_key("string1"):
cleaned["string2"] = string1
return cleaned
As seen, both 'string1' and 'string2' are required. In the clean()
method, if string2 isn't defined, I set it to a value. For my simple
case, I'm just setting it to the value of another field on the form.
What happens is that Django comes back with an error message because
'string2' is required and has no associated value. Is there any way to
set a field value that get's POST'd? Even if I make 'string2' not
required (so it winds up being an empty string), there still doesn't
seem to be a way to change the empty string to have a value. While
validation passes, the resulting POST data still shows 'string2' as an
empty string.
I thought that changing and returning the cleaned data would do it, but
apparently not.
--
Adam Stein @ Xerox Corporation Email: [email protected]
Disclaimer: Any/All views expressed
here have been proven to be my own. [http://www.csh.rit.edu/~adam/]
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=.