Form containers

References
class crispy_forms_foundation.layout.containers.Fieldset(legend, *fields, **kwargs)

Bases: crispy_forms.layout.Fieldset

It wraps fields in a <fieldset>:

Fieldset("Text for the legend",
    'form_field_1',
    'form_field_2'
)

The first parameter is the text for the fieldset legend. This text is context aware, so you can do things like :

Fieldset("Data for {{ user.username }}",
    'form_field_1',
    'form_field_2'
)
class crispy_forms_foundation.layout.containers.Container(name, *fields, **kwargs)

Bases: crispy_forms.bootstrap.Container

Overrides original Container element to get the “active” classname from Class attribute active_css_class so it’s compatible with Foundation 5 and 6.

class crispy_forms_foundation.layout.containers.TabHolder(*fields, **kwargs)

Bases: crispy_forms.bootstrap.TabHolder

Tabs holder object to wrap Tab item objects in a container:

TabHolder(
    TabItem('My tab 1', 'form_field_1', 'form_field_2'),
    TabItem('My tab 2', 'form_field_3')
)

TabHolder direct children should allways be a TabItem layout item.

A random id is builded for the tab holder if you don’t define it using css_id argument.

The first TabItem containing a field error will be marked as active if any, else this will be just the first TabItem.

render(form, form_style, context, template_pack=<SimpleLazyObject: <function get_template_pack at 0x7fb77ff1a050>>)

Re-implement almost the same code from crispy_forms but passing form instance to item render_link method.

class crispy_forms_foundation.layout.containers.VerticalTabHolder(*fields, **kwargs)

Bases: crispy_forms_foundation.layout.containers.TabHolder

VerticalTabHolder appends vertical class to TabHolder container

class crispy_forms_foundation.layout.containers.TabItem(name, *fields, **kwargs)

Bases: crispy_forms_foundation.layout.containers.Container

Tab item object. It wraps fields in a div whose default class is “tabs” and takes a name as first argument.

Tab item is also responsible of building its associated tab link with its render_link using the link_template attribute.

Example:

TabItem('My tab', 'form_field_1', 'form_field_2', 'form_field_3')

TabItem layout item has no real utility out of a TabHolder.

has_errors(form)

Find tab fields listed as invalid

Render the link for the tab-pane. It must be called after render so css_class is updated with active class name if needed.

class crispy_forms_foundation.layout.containers.AccordionHolder(*fields, **kwargs)

Bases: crispy_forms.bootstrap.Accordion

Accordion items holder object to wrap Accordion item objects in a container:

AccordionHolder(
    AccordionItem("group name", "form_field_1", "form_field_2"),
    AccordionItem("another group name", "form_field"),
)

AccordionHolder direct children should allways be a AccordionItem layout item.

A random id is builded for the accordion holder if you don’t define it using css_id argument.

The first AccordionItem containing a field error will be marked as active if any, else this will be just the first AccordionItem.

render(form, form_style, context, template_pack=<SimpleLazyObject: <function get_template_pack at 0x7fb77ff1a050>>, **kwargs)

Re-implement almost the same code from crispy_forms but using form instance to catch field errors.

class crispy_forms_foundation.layout.containers.AccordionItem(name, *fields, **kwargs)

Bases: crispy_forms.bootstrap.AccordionGroup

Accordion item object. It wraps given fields inside an accordion tab. It takes accordion tab name as first argument.

The item name is also slugified to build an id for the tab if you don’t define it using css_id argument.

Example:

AccordionItem("group name", "form_field_1", "form_field_2")