This module complements the django forms library by adding ajax functionality, inline forms, and custom layout based on uni-form style. The module has been adapted from django-uni-form.
Using uniforms to render form is easy:
from djcms.utils.uniforms import FormLayout, Fieldset, blockLabels2
class MyForm(uniforms.Form):
name = forms.CharField()
#create the form layout
layout = FormLayout(Fieldset('name', css_class=blockLabels2))
There are three types of layout: inlineLabels, blockLabels and blockLabels2 (the default).
inlineLabels, blockLabels, blockLabels2.
Main class for defining the layout of a uniform. For example:
class NoteForm(forms.Form):
name = forms.CharField()
dt = forms.DateTimeField()
content = forms.TextField()
layout = FormLayout(Fieldset('name', 'dt'),
Fieldset('description'),
Row('password1','password2'),
Html('<img src="/media/somepicture.jpg"/>'))
String id for layout.
Template file name or None
The default layout style of UniFormElement in self. One of layout types. Default inlineLabels.
Add fields to all fields. A field must be an instance of UniFormElement.
Render the uniform layout or form.
Base class for elements in a uniform FormLayout.
The class used for the form element, one of layout types. If missing the FormLayout.default_style will be used.
Extra css class for the element. Default None.
An optional template file name for rendering the element. Default None.
Render the uniform element. This function is called the the instance of FormLayout which contains self.
A UniFormElement which renders to a <fieldset>.
A UniFormElement which renders to a <div>.
A UniFormElement whiche defines a set of columns. Renders to a set of <div>.
A UniFormElement which renders to self.
Class holding a form, formsets and helper for displaying forms as uni-forms.
Serialize form errors for AJAX-JSON interaction.
Render the uniform by rendering individual forms, inline forms and inputs.