Forms¶
-
class
ajaxviews.forms.DefaultFormActions[source]¶ Bases:
crispy_forms.layout.LayoutObjectCrispy layout object that renders form actions depending on options defined in
form.optsproperty.Keyword arguments available in
opts:Variables: - success_url (str) – Url to redirect to on successful form save.
- delete_url (str) – Delete view that’s requested on form delete.
- delete_success_url (str) – Url to redirect view on successful form deletion.
- form_actions_template (str) – Template to render form actions in. Default:
'ajaxviews/_form_controls.html' - preview_stage (int) – If form preview is displayed render a back button.
- modal_form (bool) – True if form is displayed in a bootrap modal. Default:
False - delete_confirmation (bool) – Display a bootstrap confirmation popover if delete button is clicked.
- form_cfg (dict) – Additional data needed to process form save passed through a hidden input field. Dictionary
is stringified and automatically parsed again when calling
FormMixin.cleaned_form_cfg().
-
class
ajaxviews.forms.DefaultFormHelper(*args, **kwargs)[source]¶ Bases:
crispy_forms.helper.FormHelperCrispy form helper used to define default form action control.
A
data-asynchtml property is added to the form tag.
-
class
ajaxviews.forms.FormMixin(*args, **kwargs)[source]¶ Bases:
objectMixin that handels instantiation of crispy form helper and options passed in the form’s init kwargs.
Variables: opts (dict) – -
cleaned_form_cfg¶ Loads the stringified
form_cfgincleaned_datato return a python dictionary object.Returns: form cfg dictionary
-
helper¶ The
DefaultFormHelperis instantiated only once when this helper property is accessed first.Assign your own form helper if you want to override the default behavior.
This renders hidden fields and appends form actions by default.
Returns: Form helper instance
-
layout¶ Get or set the crispy form helper layout object. If you set a new layout the form actions are appended automatically.
-
-
class
ajaxviews.forms.GenericModelForm(*args, **kwargs)[source]¶ Bases:
ajaxviews.forms.FormMixin,django.forms.models.ModelFormGeneric form for use with a corresponding model.
Get model instance with pk of related model from the calling view.
Parameters: - model – Django model class.
- key – Keyword argument to get the value used to retrieve the model instance. If not specified it
expects a single key in
related_obj_idsthat’s used.
Returns: Model instance.
-
class
ajaxviews.forms.ModelFormSet(*args, **kwargs)[source]¶ Bases:
django.forms.models.BaseModelFormSetUse this form to render form actions at the bottom of the formset.
Variables: form_actions_template (str) – Template to render save and cancel buttons. Be sure to use the {{ success_url }}tag for your cancel button if you want to override this template.
-
class
ajaxviews.forms.SimpleForm(*args, **kwargs)[source]¶ Bases:
ajaxviews.forms.FormMixin,django.forms.forms.FormGeneric form for use without a corresponding model. Also used to display a preview before saving a form.
Variables: