Buttons¶
- References
Bases:
crispy_forms.layout.ButtonHolder
It wraps fields in an element
<div class="button-holder">
.This is where you should put Layout objects that render to form buttons like Submit. It should only hold
HTML
andBaseInput
inherited objects.Example:
ButtonHolder( HTML(<span style="display: hidden;">Information Saved</span>), Submit('Save', 'Save') )
Bases:
crispy_forms_foundation.layout.buttons.ButtonHolder
Act like
ButtonHolder
but add apanel
class name on the maindiv
.
Bases:
crispy_forms_foundation.layout.buttons.ButtonHolder
Act like
ButtonHolder
but add acallout
class name on the maindiv
.
Bases:
crispy_forms.layout.LayoutObject
It wraps fields in an element
<div class="button-group">
.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:
ButtonGroup( Submit('Save', 'Save'), Button('Cancel', 'Cancel'), )
Bases:
crispy_forms_foundation.layout.buttons.InputButton
This is the old Button object that inherit from
InputButton
for backward compatibility.If you want to stand for an input button, you are invited to use
InputButton
instead to avoid problem whenButtonElement
will become the newButton
object.
Bases:
crispy_forms_foundation.layout.buttons.InputSubmit
This is the old Button object that inherit from
InputSubmit
for backward compatibility.If you want to stand for an input button, you are invited to use
InputSubmit
instead to avoid problem whenButtonSubmit
will become the newSubmit
object.
Bases:
crispy_forms_foundation.layout.buttons.InputReset
This is the old Button object that inherit from
InputReset
for backward compatibility.If you want to stand for an input button, you are invited to use
InputReset
instead to avoid problem whenButtonReset
will become the newReset
object.
Bases:
crispy_forms.layout.BaseInput
Used to create a Submit input descriptor for the {% crispy %} template tag:
button = InputButton('Button 1', 'Press Me!')
Note
The first argument is also slugified and turned into the id for the button.
Bases:
crispy_forms.layout.BaseInput
Used to create a Submit button descriptor for the {% crispy %} template tag:
submit = Submit('Search the Site', 'search this site')
Bases:
crispy_forms.layout.BaseInput
Used to create a Reset button input descriptor for the
{% crispy %}
template tag:reset = Reset('Reset This Form', 'Revert Me!')
Bases:
crispy_forms.layout.BaseInput
Contrary to
Button
, ButtonElement purpose use a<button>
element to create a clickable form button and accept an argument to add free content inside element.Advantage of
<button>
is to accept almost any HTML content inside element.button = ButtonElement('name', 'value', content="<span>Press Me!</span>")
Note
- First argument is for
name
attribute and also turned into the id for the button; - Second argument is for
value
attribute and also for element content if not given; - Third argument is an optional named argument
content
, if given it will be appended inside element instead ofvalue
. Content string is marked as safe so you can put anything you want;
- First argument is for
Bases:
crispy_forms_foundation.layout.buttons.ButtonElement
Create a submit button following the
ButtonElement
behaviors:button = ButtonSubmit('search', 'go-search', content="<span>Search this site!</span>")
Bases:
crispy_forms_foundation.layout.buttons.ButtonElement
Create a reset button following the
ButtonElement
behaviors:button = ButtonReset('reset', 'revert' content="<span>Revert Me!</span>")