Widgets

Guide

TBD

API

class Widget([kwargs])

An HTML form widget.

A widget handles the rendering of HTML, and the extraction of data from an object that corresponds to the widget.

Arguments:
  • kwargs (Object) – widget options.
kwargs.attrs

HTML attributes for the rendered widget.

class Input([kwargs])

An HTML <input> widget.

class TextInput([kwargs])

An HTML <input type=”text”> widget

Arguments:
  • kwargs (Object) – widget options.
class PasswordInput([kwargs])

An HTML <input type="password"> widget.

Arguments:
  • kwargs (Object) – widget options additional to those specified in Input.
kwargs.renderValue

if false a value will not be rendered for this field - defaults to false.

class HiddenInput([kwargs])

An HTML <input type=”hidden”> widget.

param Object kwargs:
 widget options.
class MultipleHiddenInput([kwargs])

A widget that handles <input type=”hidden”> for fields that have a list of values.

class FileInput([kwargs])

An HTML <input type=”file”> widget.

param Object kwargs:
 widget options.
class ClearableFileInput([kwargs])
Arguments:
  • kwargs (Object) – widget options.
class DateInput([kwargs])

A <input type=”text”> which, if given a Date object to display, formats it as an appropriate date string.

Arguments:
  • kwargs (Object) – widget options additional to those specified in Input.
kwargs.format (String}

a time.strftime date format string.

class DateTimeInput([kwargs])

A <input type=”text”> which, if given a Date object to display, formats it as an appropriate datetime string.

Arguments:
  • kwargs (Object) – widget options additional to those specified in Input.
kwargs.format (String}

a time.strftime datetime format string.

class TimeInput([kwargs])

A <input type=”text”> which, if given a Date object to display, formats it as an appropriate time string.

Arguments:
  • kwargs (Object) – widget options additional to those specified in Input.
kwargs.format (String}

a time.strftime time format string.

class CheckboxInput([kwargs])

An HTML <input type="checkbox"> widget.

Arguments:
  • kwargs (Object) – widget options additional to those specified in Widget.
kwargs.checkTest

a function which takes a value and returns true if the checkbox should be checked for that value.

class Textarea([kwargs])

An HTML <textarea> widget.

Arguments:
  • kwargs (Object) – widget options

Default rows and cols HTML attributes will be used if not provided.

class Select([kwargs])

An HTML <select> widget.

Arguments:
  • kwargs (Object) – widget options additional to those specified in Widget.
kwargs.choices

choices to be used when rendering the widget, with each choice specified as an Array in [value, text] format.

class NullBooleanSelect([kwargs])

A <select> widget intended to be used with NullBooleanField.

Arguments:
  • kwargs (Object) – widget options, as specified in Select. Any choices provided will be overrridden with the specific choices this widget requires.
class SelectMultiple([kwargs])

An HTML <select> widget which allows multiple selections.

Arguments:
  • kwargs (Object) – widget options, as specified in Select.
class RadioSelect([kwargs])

Renders a single select as a list of <input type="radio"> elements.

Arguments:
  • kwargs (Object) – widget options additional to those specified in Select.
kwargs.renderer

a custom RadioFieldRenderer constructor.

class RadioFieldRenderer(name, value, attrs, choices)

An object used by RadioSelect to enable customisation of radio widgets.

Arguments:
  • name (String) – the field name.
  • value (String) – the selected value.
  • attrs (Object) – HTML attributes for the widget.
  • choices (Array) – choices to be used when rendering the widget, with each choice specified as an Array in [value, text] format.
class RadioInput(name, value, attrs, choice, index)

An object used by RadioFieldRenderer that represents a single <input type="radio">.

Arguments:
  • name (String) – the field name.
  • value (String) – the selected value.
  • attrs (Object) – HTML attributes for the widget.
  • choice (Array) – choice details to be used when rendering the widget, specified as an Array in [value, text] format.
  • index (Number) – the index of the radio button this widget represents.
class CheckboxSelectMultiple([kwargs])

Multiple selections represented as a list of <input type="checkbox"> widgets.

Arguments:
  • kwargs (Object) – widget options, as specified in Select.
class MultiWidget(widgets[, kwargs])

A widget that is composed of multiple widgets.

You’ll probably want to use this class with MultiValueField.

Arguments:
  • widgets (Array) – the list of widgets composing this widget.
  • kwargs (Object) – widget options.
class SplitDateTimeWidget([kwargs])

Splits Date input into two <input type="text"> elements.

Arguments:
  • kwargs (Object) – widget optionsadditional to those specified in MultiWidget.
  • [dateFormat] (String) – a time.strftime date format string
  • [timeFormat] (String) – a time.strftime time format string
class SplitHiddenDateTimeWidget([kwargs])

Splits Date input into two <input type="hidden"> elements.