#The signature for the SQLFORM constructor is the following: |
If deletable is set to True, the UPDATE form displays a "Check to delete" checkbox. The value of the label for this field is set via the delete_label argument.
SQLFORM(table, record=None, deletable=False)
id_label sets the label of the record "id"
The "id" of the record is not shown if showid is set to False.
fields is an optional list of field names that you want to display. If a list is provided, only fields in the list are displayed.
fields = ['name']
labels is a dictionary of field labels. The dictionary key is a field name and the corresponding value is what gets displayed as its label. If a label is not provided, web2py derives the label from the field name (it capitalizes the field name and replaces underscores with spaces).
labels = {'name':'Your Full Name:'}
col3 is a dictionary of values for the third column. For example:
col3 = {'name':A('what is this?',
_href='http://www.google.com/search?q=define:name')}
If set to True, displays the form as readonly
If set to True, displays the form as readonly
Normally, for a create/update form, only fields marked as writable=True are shown, and for readonly forms, only fields marked as readable=True are shown. Setting ignore_rw=True causes those constraints to be ignored, and all fields are displayed. This is mostly used in the appadmin interface to display all fields for each table, overriding what the model indicates.
formstyle determines the style to be used when serializing the form in html. It can be:
formstyle can also be a function which generates everything inside the FORM tag. You pass to your form constructor function two arguments, form and fields. Hints can be found in the source code file sqlhtml.py (look for functions named formstyle_)
- "table3cols" (default),
- "table2cols" (one row for label and comment, and one row for input),
- "ul" (makes an unordered list of input fields),
- "divs" (represents the form using css friendly divs, for arbitrary customization),
- "bootstrap" which uses the bootstrap form class "form-horizontal".
separator sets the string that separates form labels from form input fields.
Optional attributes are arguments starting with underscore that you want to pass to the FORM tag that renders the SQLFORM object.
_action = '.'
Optional attributes are arguments starting with underscore that you want to pass to the FORM tag that renders the SQLFORM object
_method = 'POST'
linkto is optional URLs to user-defined controllers that allow the form to deal with reference fields
upload are optional URLs to user-defined controllers that allow the form to deal with reference fields
process().accepted
form.accepts()
form.process()
" Web2py Book - Chapter 7 Forms and Validators" is licensed under Creative Common License BY-NC-ND 3.0