diff --git a/django/newforms/forms.py b/django/newforms/forms.py index 3712c676c4e..393f576dcaa 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -5,7 +5,7 @@ Form classes from django.utils.datastructures import SortedDict from django.utils.html import escape from fields import Field -from widgets import TextInput, Textarea +from widgets import TextInput, Textarea, HiddenInput from util import ErrorDict, ErrorList, ValidationError NON_FIELD_ERRORS = '__all__' @@ -194,6 +194,12 @@ class BoundField(object): "Returns a string of HTML for representing this as a -as_textarea() and as_text() are shortcuts for changing the output widget type: +as_textarea(), as_text() and as_hidden() are shortcuts for changing the output +widget type: >>> f['subject'].as_textarea() u'' >>> f['message'].as_text() u'' +>>> f['message'].as_hidden() +u'' The 'widget' parameter to a Field can also be an instance: >>> class ContactForm(Form): @@ -1450,7 +1453,8 @@ The 'widget' parameter to a Field can also be an instance: >>> print f['message'] -Instance-level attrs are *not* carried over to as_textarea() and as_text(): +Instance-level attrs are *not* carried over to as_textarea(), as_text() and +as_hidden(): >>> f['message'].as_text() u'' >>> f = ContactForm({'subject': 'Hello', 'message': 'I love you.'}) @@ -1458,6 +1462,8 @@ u'' u'' >>> f['message'].as_text() u'' +>>> f['message'].as_hidden() +u'' For a form with a