A base class to reduce the amount of code in the Input classes.
Used to create a Submit input descriptor for the {% crispy %} template tag:
button = Button('Button 1', 'Press Me!')
Note
The first argument is also slugified and turned into the id for the button.
Layout object. It wraps fields in a <div class=”buttonHolder”>
This is where you should put Layout objects that render to form buttons like Submit. It should only hold HTML and BaseInput inherited objects.
Example:
ButtonHolder(
HTML(<span style="display: hidden;">Information Saved</span>),
Submit('Save', 'Save')
)
Layout object. It wraps fields in a div whose default class is “formColumn”. Example:
Column('form_field_1', 'form_field_2')
Layout object. It wraps fields in a <div>
You can set css_id for a DOM id and css_class for a DOM class. Example:
Div('form_field_1', 'form_field_2', css_id='div-example', css_class='divs')
Layout object, It contains one field name, and you can add attributes to it easily. For setting class attributes, you need to use css_class, as class is a Python keyword.
Example:
Field('field_name', style="color: #333;", css_class="whatever", id="field_name")
Layout object. It wraps fields in a <fieldset>
Example:
Fieldset("Text for the legend",
'form_field_1',
'form_field_2'
)
The first parameter is the text for the fieldset legend. This text is context aware, so you can do things like:
Fieldset("Data for {{ user.username }}",
'form_field_1',
'form_field_2'
)
Layout object. It can contain pure HTML and it has access to the whole context of the page where the form is being rendered.
Examples:
HTML("{% if saved %}Data saved{% endif %}")
HTML('<input type="hidden" name="{{ step_field }}" value="{{ step0 }}" />')
Used to create a Hidden input descriptor for the {% crispy %} template tag.
Form Layout. It is conformed by Layout objects: Fieldset, Row, Column, MultiField, HTML, ButtonHolder, Button, Hidden, Reset, Submit and fields. Form fields have to be strings. Layout objects Fieldset, Row, Column, MultiField and ButtonHolder can hold other Layout objects within. Though ButtonHolder should only hold HTML and BaseInput inherited classes: Button, Hidden, Reset and Submit.
Example:
helper.layout = Layout(
Fieldset('Company data',
'is_company'
),
Fieldset(_('Contact details'),
'email',
Row('password1', 'password2'),
'first_name',
'last_name',
HTML('<img src="/media/somepicture.jpg"/>'),
'company'
),
ButtonHolder(
Submit('Save', 'Save', css_class='button white'),
),
)
MultiField container. Renders to a MultiField <div>
Layout object. For fields with MultiWidget as widget, you can pass additional attributes to each widget.
Example:
MultiWidgetField(
'multiwidget_field_name',
attrs=(
{'style': 'width: 30px;'},
{'class': 'second_widget_class'}
),
)
Note
To override widget’s css class use class not css_class.
Used to create a Reset button input descriptor for the {% crispy %} template tag:
reset = Reset('Reset This Form', 'Revert Me!')
Note
The first argument is also slugified and turned into the id for the reset.