Buttons

References
class crispy_forms_foundation.layout.buttons.ButtonHolder(*fields, **kwargs)

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 and BaseInput inherited objects.

Example:

ButtonHolder(
    HTML(<span style="display: hidden;">Information Saved</span>),
    Submit('Save', 'Save')
)
class crispy_forms_foundation.layout.buttons.ButtonHolderPanel(field, *args, **kwargs)

Bases: crispy_forms_foundation.layout.buttons.ButtonHolder

Act like ButtonHolder but add a panel class name on the main div.

class crispy_forms_foundation.layout.buttons.ButtonHolderCallout(field, *args, **kwargs)

Bases: crispy_forms_foundation.layout.buttons.ButtonHolder

Act like ButtonHolder but add a callout class name on the main div.

class crispy_forms_foundation.layout.buttons.ButtonGroup(*fields, **kwargs)

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'),
)
class crispy_forms_foundation.layout.buttons.Button(name, value, **kwargs)

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 when ButtonElement will become the new Button object.

class crispy_forms_foundation.layout.buttons.Submit(name, value, **kwargs)

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 when ButtonSubmit will become the new Submit object.

class crispy_forms_foundation.layout.buttons.Reset(name, value, **kwargs)

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 when ButtonReset will become the new Reset object.

class crispy_forms_foundation.layout.buttons.InputButton(name, value, **kwargs)

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.

class crispy_forms_foundation.layout.buttons.InputSubmit(name, value, **kwargs)

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')
class crispy_forms_foundation.layout.buttons.InputReset(name, value, **kwargs)

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!')
class crispy_forms_foundation.layout.buttons.ButtonElement(field, *args, **kwargs)

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 of value. Content string is marked as safe so you can put anything you want;
class crispy_forms_foundation.layout.buttons.ButtonSubmit(field, *args, **kwargs)

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>")
class crispy_forms_foundation.layout.buttons.ButtonReset(field, *args, **kwargs)

Bases: crispy_forms_foundation.layout.buttons.ButtonElement

Create a reset button following the ButtonElement behaviors:

button = ButtonReset('reset', 'revert'
                     content="<span>Revert Me!</span>")