Form rendering helpers.
- Automatically add appropriate HTML5
type
,required
andmaxlength
attributes to form fields. - Automatically add
date
,time
, anddatetime
CSS classes to appropriate form fields. - Easily add custom
placeholders
to form fields by editing adict
. - Easily render forms in your templates in a well-designed standardised way that makes front-end development easier.
The full documentation is at https://thecut-forms.readthedocs.org.
Install thecut-forms
using the installation
.
Use one of the many available :pydjango.forms.Form
mixins on your :pydjango.forms.Form
:
from django import forms
from thecut.forms import EmailTypeMixin, TimeClassMixin
class MyForm(EmailTypeMixin, TimeClassMixin, forms.Form):
foo = forms.EmailField(required=True)
bar = forms.TimeField(required=True)
Or use :pythecut.forms.forms.FormMixin
to get them all at once:
from django import forms
from thecut.forms import FormMixin
class MyForm(FormMixin, forms.Form):
foo = forms.CharField(required=True)
See mixins
for more information.
In your template, use the forms/_form.html
snippet to easily render your forms:
{% include "forms/_form.html" %}
See templates
for more information.
See credits
.