cc1
v2.1
CC1 source code docs
|
BetterForm
and BetterModelForm
are subclasses of Form and ModelForm that allow for declarative definition of fieldsets and row_attrs in an inner Meta class.
More...
Public Member Functions | |
def | __init__ |
def | __iter__ |
def | fieldsets |
BetterForm
and BetterModelForm
are subclasses of Form and ModelForm that allow for declarative definition of fieldsets and row_attrs in an inner Meta class.
The row_attrs declaration is a dictionary mapping field names to dictionaries of attribute/value pairs. The attribute/value dictionaries will be flattened into HTML-style attribute/values (i.e. {'style': 'display: none'} will become style="display:
none"
), and will be available as the row_attrs
attribute of the BoundField
. Also, a CSS class of "required" or "optional" will automatically be added to the row_attrs of each BoundField
, depending on whether the field is required.
The fieldsets declaration is a list of two-tuples very similar to the fieldsets
option on a ModelAdmin class in django.contrib.admin
.
The first item in each two-tuple is a name for the fieldset (must be unique, so that overriding fieldsets of superclasses works), and the second is a dictionary of fieldset options
Valid fieldset options in the dictionary include:
fields
(required): A tuple of field names to display in this fieldset.
classes:
A list of extra CSS classes to apply to the fieldset.
legend:
This value, if present, will be the contents of a legend
tag to open the fieldset. If not present the unique name of the fieldset will be used (so a value of '' for legend must be used if no legend is desired.)
description:
A string of optional extra text to be displayed under the legend
of the fieldset.
When iterated over, the fieldsets
attribute of a BetterForm
(or BetterModelForm
) yields Fieldsets
. Each Fieldset
has a name attribute, a legend attribute, and a description attribute, and when iterated over yields its BoundFields
.
For backwards compatibility, a BetterForm
or BetterModelForm
can still be iterated over directly to yield all of its BoundFields
, regardless of fieldsets.
For more detailed examples, see the doctests in tests/__init__.py.
def src.wi.utils.forms.BetterBaseForm.__init__ | ( | self, | |
args, | |||
kwargs | |||
) |