Package Camelot :: Package camelot :: Package view :: Module forms :: Class Form
[frames] | no frames]

Class Form

source code


Base Form class to put fields on a form. 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'])
../_static/form/form.png
Instance Methods
 
__init__(self, content, scrollbars=False, columns=1)
eg : with 2 columns, the fields ['street', 'city', 'country'] will be ordered as :
source code
 
get_fields(self)
Returns: the fields, visible in this form
source code
 
removeField(self, original_field)
Remove a field from the form, This function can be used to modify inherited forms.
source code
 
replaceField(self, original_field, new_field)
Replace a field on this form with another field. This function can be used to modify inherited forms.
source code
 
add_field(self, new_field) source code
 
__unicode__(self) source code
 
render(*args, **kwargs)
of (label, widget editor)
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, content, scrollbars=False, columns=1)
(Constructor)

source code 

eg : with 2 columns, the fields ['street', 'city', 'country'] will be ordered as :

street

city

country

 
Parameters:
  • content - a list with the field names and forms to render
  • columns - the number of columns in which to order the fields.
Overrides: object.__init__

get_fields(self)

source code 
Returns:
the fields, visible in this form

removeField(self, original_field)

source code 
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

replaceField(self, original_field, new_field)

source code 

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.

render(*args, **kwargs)

source code 
of (label, widget editor)
Parameters:
  • widgets - a dictionary mapping each field in this form to a tuple
Returns:
a QWidget into which the form is rendered
Decorators:
  • @gui_function