Widgets

class crispy_forms_gds.widgets.DateInputWidget(*args, **kwargs)

A DateInputWidget defines the styling of the set of fields for displaying the value for a DateInputField.

A custom widget was needed for two reasons. First the CSS classes needed to style the fields and set their width reduces the code need to add a Date input component to a form. Second, the Design System requires labels for the individual fields. That’s not supported out of the box by a MultiValueField so the labels are added as a custom attribute and rendered with the correct markup in the template. The template also pops the label from the widget so it does not also get added as an attribute.

decompress(value)

Convert a date into values for the day, month and year so it can be displayed in the widget’s fields.

Parameters

value (date) – the date to be displayed

Returns

a 3-tuple containing the day, month and year components of the date.

property media

Media for a multiwidget is the combination of all media of the subwidgets.