Fieldset

class crispy_forms_gds.layout.Fieldset(*fields, legend=None, legend_size=None, legend_tag=None, **kwargs)

A layout object for displaying groups of fields.

The contents of a Fieldset are be one or more LayoutObjects: fields, buttons, composed layouts, etc. You can give the <fieldset> a <legend> title, set the size of the font used and wrap the <legend> in a heading tag if necessary.

Examples:

Fieldset('form_field_1', 'form_field_2')
Fieldset('form_field_1', 'form_field_2', legend="title")
Fieldset('form_field_1', 'form_field_2', legend="title", legend_tag="h1")
Fieldset('form_field_1', 'form_field_2', legend="title", legend_size="xl")
Parameters
  • legend (str, optional) – the title displayed in a <legend>.

  • legend_size (str, optional) – the size of the title: ‘s’, ‘m’, ‘l’ or ‘xl’. It’s more readable if you use the contants on the Size class.

  • legend_tag (str, optional) – an HTML tag that wraps the <legend>. Typically this is ‘h1’ so the <legend> also acts as the page title.

  • css_id (str, optional) – an unique identifier for the fieldset.

  • css_class (str, optional) – the names of one or more CSS classes that will be added to the <fieldset>. The basic Design System CSS classes will be added automatically. This parameter is for any extra styling you want to apply.

  • template (str, optional) – the path to a template that overrides the one provided by the template pack.

  • *fields – a list of LayoutObjects objects that make up the Fieldset contents.

  • **kwargs – any additional attributes you want to add to the <fieldset>.