1 2 3 4 5 6 7 8 9 10 11 | from django import forms
hiddenValues = forms.Form()
value0 = 17
hiddenValues.fields['value0'] = forms.CharField(initial=value0,
widget=forms.widgets.HiddenInput())
# pass the form to your template
# render it as you like, e.g. with form.as_p
|
More like this
- Complex Formsets, Redux by smagala 3 years, 2 months ago
- Using Textarea by joshua 6 years, 2 months ago
- Bulk Insert Manager by ocdcoder 2 years, 3 months ago
- Dynamically change a form select widget to a hidden widget by epicserve 3 years, 10 months ago
- Type checking templatetag filters by marcorogers 3 years, 2 months ago
Comments
Great tip. Works like a charm.
#
Not sure what the author means about documentation for widgets - they are extensively documented here:
http://docs.djangoproject.com/en/dev/ref/forms/fields/#widget
and here:
http://docs.djangoproject.com/en/dev/ref/forms/widgets/
#