From 2f53d342f1ce2fb36cddbd90e24c4fda86389c27 Mon Sep 17 00:00:00 2001 From: Moritz Sichert Date: Mon, 10 Aug 2015 13:23:24 +0200 Subject: [PATCH] Fixed #12856 -- Documented BoundField API. --- docs/ref/forms/api.txt | 237 ++++++++++++++++++++++++------------ docs/ref/forms/widgets.txt | 10 ++ docs/topics/forms/index.txt | 5 + 3 files changed, 171 insertions(+), 81 deletions(-) diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt index ca9e4d868fc..a8d2fa77ff2 100644 --- a/docs/ref/forms/api.txt +++ b/docs/ref/forms/api.txt @@ -767,6 +767,8 @@ method you're using::

Sender:

Cc myself:

+.. _ref-forms-error-list-format: + Customizing the error list format ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -792,10 +794,10 @@ Python 2)::

Cc myself:

More granular output -~~~~~~~~~~~~~~~~~~~~ +-------------------- -The ``as_p()``, ``as_ul()`` and ``as_table()`` methods are simply shortcuts for -lazy developers -- they're not the only way a form object can be displayed. +The ``as_p()``, ``as_ul()``, and ``as_table()`` methods are simply shortcuts -- +they're not the only way a form object can be displayed. .. class:: BoundField @@ -830,107 +832,180 @@ The field-specific output honors the form object's ``auto_id`` setting:: >>> print(f['message']) -For a field's list of errors, access the field's ``errors`` attribute. +Attributes of ``BoundField`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. attribute:: BoundField.data + + This property returns the data for this :class:`~django.forms.BoundField` + extracted by the widget's :meth:`~django.forms.Widget.value_from_datadict` + method, or ``None`` if it wasn't given:: + + >>> unbound_form = ContactForm() + >>> print(unbound_form['subject'].data) + None + >>> bound_form = ContactForm(data={'subject': 'My Subject'}) + >>> print(bound_form['subject'].data) + My Subject .. attribute:: BoundField.errors -A list-like object that is displayed as an HTML ``