Classes to layout fields on a form. These are mostly used for specifying the form_display attribute in Admin classes, but they can be used on their own as well. Form classes can be used recursive.
Helper class for TabForm to delay the creation of tabs to the moment the tab is shown.
Base Form class to put fields on a form. The base class of a form is a list. So the form itself is nothing more than a list of field names or sub-forms. A form can thus be manipulated using the list’s method such as append or insert.
A form can be converted to a QT widget by calling its render method. The base form uses the QFormLayout to render a form:
class Admin(EntityAdmin):
form_display = Form(['title', 'short_description', 'director', 'release_date'])
..image:: /_static/form/form.png
Remove a field from the form, This function can be used to modify inherited forms.
Parameters: | original_field – the name of the field to be removed |
---|---|
Returns: | True if the field was found and removed |
Parameters: |
|
---|---|
Returns: | a QWidget into which the form is rendered |
Generator for lines of text in Office Open XML representing this form, using tables :param obj: the object or entity that will be rendered :param delegates: a dictionary mapping field names to their delegate
Replace a field on this form with another field. This function can be used to modify inherited forms.
:param original_field : the name of the field to be replace :param new_field : the name of the new field :return: True if the original field was found and replaced.
Put different fields into a grid, without a label. Row or column labels can be added using the Label form:
GridForm([['title', 'short_description'], ['director','release_date']])
Renders a form within a QGroupBox:
class Admin(EntityAdmin):
form_display = GroupBoxForm('Movie', ['title', 'short_description'])
Render different forms in a horizontal box:
form = forms.HBoxForm([['title', 'short_description'], ['director', 'release_date']])
Render a label with a QLabel
Render forms within a QTabWidget:
from = TabForm([('First tab', ['title', 'short_description']),
('Second tab', ['director', 'release_date'])])
Add a tab to the form
Parameters: |
|
---|
Render different forms or widgets in a vertical box:
form = forms.VBoxForm([['title', 'short_description'], ['director', 'release_date']])
Renders a single widget without its label, typically a one2many widget
Convert a python data structure to a form, using the following rules :
- if structure is an instance of Form, return structure
- if structure is a list, create a Form from this list
This function is mainly used in the Admin class to construct forms out of the form_display attribute