Form Mixins¶
The following mixins can be applied to any Form-type object.
EmailTypeMixin¶
-
class
thecut.forms.forms.EmailTypeMixin(*args, **kwargs)¶ A mixin for a
Formthat sets the HTML5emailinput type on any childEmailFieldinstances.
RequiredMixin¶
-
class
thecut.forms.forms.RequiredMixin(*args, **kwargs)¶ A mixin for a
Formthat sets the HTML5requiredattribute on any childFieldinstances that is required.This mixin does not apply the required attribute to fields using
RadioSelectandCheckboxSelectMultipleas the HTML5requiredattribute does not behave as (usually) expected on these widgets.
MaxLengthMixin¶
-
class
thecut.forms.forms.MaxLengthMixin(*args, **kwargs)¶ A mixin for a
Formthat sets the HTML5maxlengthattribute on any childFieldinstances using theTextareawidget.A
max_lengthmust be specified on theField.
PlaceholderMixin¶
-
class
thecut.forms.forms.PlaceholderMixin(*args, **kwargs)¶ A mixin for a
Formthat allows you to easily set the HTML5placeholderwidget on a childField.To add a
placeholderto aField, specify it in aplaceholdersdicton theForm‘sMetaclass. For example:class MyForm(forms.Form): foo = forms.CharField() class Meta(object): placeholders = { 'foo': 'Enter some text here.' }
TimeClassMixin¶
-
class
thecut.forms.forms.TimeClassMixin(*args, **kwargs)¶ A mixin for a
Formthat adds atimeCSS class on any childFieldinstances using theTimeInputwidget..
DateClassMixin¶
-
class
thecut.forms.forms.DateClassMixin(*args, **kwargs)¶ A mixin for a
Formthat adds adateCSS class on any childFieldinstances using theDateInputwidget..
DateTimeClassMixin¶
-
class
thecut.forms.forms.DateTimeClassMixin(*args, **kwargs)¶ A mixin for a
Formthat adds adatetimeCSS class on any childFieldinstances using theDateTimeInputwidget..
FormMixin¶
In order to make it easy to use all of the above mixins, we have provided
thecut.forms.forms.FormMixin which inherits from all other mixins.
-
class
thecut.forms.forms.FormMixin(*args, **kwargs)¶ Bases:
thecut.forms.forms.DateTimeClassMixin,thecut.forms.forms.DateClassMixin,thecut.forms.forms.EmailTypeMixin,thecut.forms.forms.MaxLengthMixin,thecut.forms.forms.PlaceholderMixin,thecut.forms.forms.RequiredMixin,thecut.forms.forms.TimeClassMixinForm mixin.
Used to extend a standard Django
Formclass with useful/common behaviour.