From e081160706cc7ac7943752632049a6dbe420bc6f Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Mon, 8 Mar 2010 03:18:22 +0000 Subject: [PATCH] Fixed #13037 -- Added documentation for the css_classes() helper class. Thanks to marcusf for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12707 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/ref/forms/api.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt index c313eb5c6b..0d174ea4af 100644 --- a/docs/ref/forms/api.txt +++ b/docs/ref/forms/api.txt @@ -645,6 +645,25 @@ when printed:: >>> str(f['subject'].errors) '' +.. versionadded:: 1.2 + +When you use Django's rendering shortcuts, CSS classes are used to +indicate required form fields or fields that contain errors. If you're +manually rendering a form, you can access these CSS classes using the +``css_classes`` method:: + + >>> f = ContactForm(data) + >>> f['message'].css_classes() + 'required' + +If you want to provide some additional classes in addition to the +error and required classes that may be required, you can provide +those classes as an argument:: + + >>> f = ContactForm(data) + >>> f['message'].css_classes('foo bar') + 'foo bar required' + .. _binding-uploaded-files: Binding uploaded files to a form