from gluon.tools import Crud
crud = Crud(db)
def data(): return dict(form=crud()) |
Enforce authentication on all crud forms
crud.settings.auth = auth
Specify the controller that defines the data function which returns the crud object
crud.settings.controller = 'default'
crud.settings.create_next = URL('index')
Specify the URL to redirect to after a successful "update" record:
crud.settings.update_next = URL('index')
Specify the URL to redirect to after a successful "delete" record.
crud.settings.delete_next = URL('index')
To specify the URL to be used for linking uploaded files.
crud.settings.download_url = URL('download')
To specify extra functions to be executed after standard validation procedures for crud.create forms
crud.settings.create_onvalidation = StorageList() #StorageList is the same as a Storage object, they are both defined in the file "gluon/storage.py", but it defaults to [] as opposed to None. It allows the following syntax:
crud.settings.create_onvalidation.mytablename.append(lambda form:....)
To specify extra functions to be executed after standard validation procedures for crud.update forms.
crud.settings.update_onvalidation = StorageList()
To specify extra functions to be executed after completion of crud.create forms: .
crud.settings.create_onaccept = StorageList()
To specify extra functions to be executed after completion of crud.update forms.
crud.settings.update_onaccept = StorageList()
To specify extra functions to be executed after completion of crud.update i. record is deleted:
crud.settings.update_ondelete = StorageList()
To specify extra functions to be executed after completion of crud.delete:
crud.settings.delete_onaccept = StorageList()
To determine whether the "update" forms should have a "delete" button.
crud.settings.update_deletable = True
To determine whether the "update" forms should show the id of the edited record.
crud.settings.showid = False
To determine whether forms should keep the previously inserted values or reset to default after successful submission.
crud.settings.keepvalues = False
Crud always detects whether a record being edited has been modified by a third party in the time between the time when the form is displayed and the time when it is submitted. This behavior is equivalent to form.process(detect_record_change=True)
crud.settings.detect_record_change = True
Change form style: 'table3cols' or 'table2cols' or 'divs' or 'ul'
crud.settings.formstyle = 'table3cols' or 'table2cols' or 'divs' or 'ul'
You can set the separator in all crud forms.
crud.settings.label_separator = ':'
crud.settings.captcha = None
crud.settings.create_captcha = None
crud.settings.update_captcha = None
Create record
Deletes the record
Read-only form
Search records
Returns a list of records
Update record
" web2py Book Chapter 7: Forms and Validatators" is licensed under Creative Common License BY-NC-ND 3.0