summaryrefslogtreecommitdiff
path: root/docs/ref/forms
diff options
context:
space:
mode:
authorThomas Tanner <tanner@gmx.net>2015-03-16 01:33:59 +0100
committerTim Graham <timograham@gmail.com>2015-03-16 09:12:57 -0400
commit28986da4ca167ae257abcaf7caea230eca2bcd80 (patch)
tree7db7c27812e72b860c088d98a7b36d2b1f016023 /docs/ref/forms
parent39573a11db694a584de6ca2a858fa05ec4ea13e1 (diff)
Fixed #5986 -- Added ability to customize order of Form fields
Diffstat (limited to 'docs/ref/forms')
-rw-r--r--docs/ref/forms/api.txt25
1 files changed, 25 insertions, 0 deletions
diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt
index ec50f02d42..3bc39cdc0f 100644
--- a/docs/ref/forms/api.txt
+++ b/docs/ref/forms/api.txt
@@ -700,6 +700,31 @@ example, in the ``ContactForm`` example, the fields are defined in the order
``subject``, ``message``, ``sender``, ``cc_myself``. To reorder the HTML
output, just change the order in which those fields are listed in the class.
+There are several other ways to customize the order:
+
+.. attribute:: Form.field_order
+
+.. versionadded:: 1.9
+
+By default ``Form.field_order=None``, which retains the order in which you
+define the fields in your form class. If ``field_order`` is a list of field
+names, the fields are ordered as specified by the list and remaining fields are
+appended according to the default order. Unknown field names in the list are
+ignored. This makes it possible to disable a field in a subclass by setting it
+to ``None`` without having to redefine ordering.
+
+You can also use the ``Form.field_order`` argument to a :class:`Form` to
+override the field order. If a :class:`~django.forms.Form` defines
+:attr:`~Form.field_order` *and* you include ``field_order`` when instantiating
+the ``Form``, then the latter ``field_order`` will have precedence.
+
+.. method:: Form.order_fields(field_order)
+
+.. versionadded:: 1.9
+
+You may rearrange the fields any time using ``order_fields()`` with a list of
+field names as in :attr:`~django.forms.Form.field_order`.
+
How errors are displayed
~~~~~~~~~~~~~~~~~~~~~~~~