Forms¶
- class djgentelella.forms.forms.GTBaseModelFormSet(data=None, files=None, auto_id='id_%s', prefix=None, queryset=None, *, initial=None, **kwargs)¶
- add_fields(form, index)¶
Add a hidden field for the object’s primary key.
- ordering_widget¶
alias of
HiddenInput
- class djgentelella.forms.forms.GTForm(*args, **kwargs)¶
GTForm is the basis of form management, it does the work of django forms.Form, including enhancements and boostrap rendering, so it should be inherited from this form, rather than forms.Form.
Example of use:
from djgentelella.forms.forms import GTForm class MyForm(GTForm): myfield = forms.TextField()
Using with forms.ModelForm
from djgentelella.forms.forms import GTForm class MyForm(GTForm, forms.ModelForm): myfield = forms.TextField() class Meta: model = MyModel
Creating an instance and specify how render it.
myform = myGTForm(render_type='as_inline', ... )
- as_grid()¶
Allow you to arrange the form fields in rows and cols, When you use this render needs to fill grid_representation attribute in your form Return this form rendered as HTML using grid bootstrap approach.,
grid_representation=[ [ ['key'],[], [] ], [ [], [] ], ]
- as_horizontal()¶
Return this form rendered as HTML using as_horizontal bootstrap approach.
- as_inline()¶
Return this form rendered as HTML using as_inline bootstrap approach.
- as_plain()¶
Returns this form rendered as HTML using as_plain bootstrap approach.
- property grid¶
Example of return structure:
[ [ [forms.Field],[], [] ], [ [], [] ], ]
- property media¶
Return all media required to render the widgets on this form.
- class djgentelella.forms.forms.GTFormSet(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, form_kwargs=None, error_messages=None)¶
This class Allow to manage FormSet using GTForm and Widgets, provide an implementation to integrate with django formset system.
- add_fields(form, index)¶
A hook for adding extra fields on to each form instance.
- ordering_widget¶
alias of
HiddenInput