This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.
If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.
Warning: this is alpha code. The API and the behavior of this extension is subject to change.
- autoform db-table conn #!key keyword-parametersprocedure
The following keyword parameters are available:
- a list of extra fields to be rendered (i.e., fields which don't exist in the given table). See the db-field record. The default value is '().
- a boolean which indicates whether the database connection should be closed by autoform. The default value is #f.
- an alist mapping database field names (symbols) to more meaningful labels (strings). Example:
labels: '((user . "User name") (address . "Address"))
The default value is '().
- an alist mapping database field names (symbols) to widgets (one-argument procedures). Autoform tries to pick the best widget for fields based on their type, but if you want to change it, you can use this keyword parameter.
widgets: '((user . ,(lambda (var) var)))
The default value is '().
- an alist mapping database field names (symbols) to default values to be used when rendering the form. The default value is '().
- a list of fields (symbols) to be considered mandatory, even if the database structure doesn't require them to be mandatory. The default value is '().
- a list of field names (symbols) to be rendered as disabled. The default value is '().
- a list of field names (symbols) to be rendered as read-only. The default value is '().
- a list of field names (symbols) to be rendered as password input boxes. The default value is '().
- the HTTP method (a symbol) to be used for the form submission. The default value is 'post.
- the form action (a string or #f). The default value is #f.
- the label (a string or #f) for the submit widget. The default value is #f.
- when set, indicates that no explicit layout markup should be used (the layout will be set by CSS). Its value is a list of field names representing what fields and the order they should be rendered. The default value is #f.
- when set, indicates that an unordered [X]HTML list should be used to layout the form fields. Its value a list of field names representing what fields and the order they should be rendered. The default value is #f.
- when set, indicates that an [X]HTML table should be used to layout the form fields. Its value is a list of lists ofield names. The default value is #f.
- an one-argument procedure (the field label) which generates text to indicate which fields are mandatory. The default value is (lambda (_) (string-append _ " (*)")).
Unless when explicitly set by the widgets keyword parameter, the database fields are rendered according to their types. Autoform considers the following mapping:
Database type Widget text [X]HTML textarea hidden (not actually a db type, but can be used by make-db-field) [X]HTML hidden input password (not actually a db type, but can be used by make-db-field) [X]HTML password input boolean [X]HTML checkbox input timestamp*, date* [X]HTML text input any other type [X]HTML text input
- make-db-field type maxlen mandatory?procedure
Return a db-field object which can be used with autoform's extra-fields keyword parameter.
type (a string) can be any valid database type (e.g., "boolean", "text") or the special ones: "password" and "hidden".
maxlen is the maximum length of the input for the field (for those which length makes sense). When it doesn't make sense (e.g., "boolean"), #f can be used.
mandatory? is a boolean to indicate whether the field is mandatory.
- Added required eggs to the .meta file (thanks to Stephen Eilert for reporting this).
- Initial release