Form Storage -- Flat Table: Difference between revisions
From IHRIS Wiki
Line 19: | Line 19: | ||
***type: Required scalar node. The formfield type of this node, e.g. INT, INT_LIST. | ***type: Required scalar node. The formfield type of this node, e.g. INT, INT_LIST. | ||
*parent: Optional parent node. If not present, this form has no parent and getParent() returns 0. It has the following child nodes: | *parent: Optional parent node. If not present, this form has no parent and getParent() returns 0. It has the following child nodes: | ||
** | **enabled: Optional scalar node. If set and evaluates to true, it means we should return a non-trivial parent id. | ||
**col: Required scalar node. Specifies a "column" of the table to be used as the id for the parent. You are responsible for back-tics. | **col: Required scalar node. Specifies a "column" of the table to be used as the id for the parent. You are responsible for back-tics. | ||
**function: Optional scalar node. Specifies a SQL function whose result will be referenced as the value in 'col.' It will be used as the id for the form. If it is not set, then the value under 'col' is really a column of the table. | **function: Optional scalar node. Specifies a SQL function whose result will be referenced as the value in 'col.' It will be used as the id for the form. If it is not set, then the value under 'col' is really a column of the table. |
Revision as of 11:58, 20 March 2009
The Flat Table storage mechanism allows you to map any flat table that you have in your database into a form.
Storage Options in Magic Data
To specify that the form $form has a flat table storage mechanism set by setting
modules/forms/forms/$form/storage
to have value flat.
The options specifying a flat table storage for $form are stored at:
/modules/forms/forms/$form/storage_options/flat
It has the following structure:
- table: Required scalar node. The table to use. E.g. my_table, `my weird_table`, `some_other_database`.`table`. You are responsible for back-tics if required.
- id: Required parent node. The data defining how to associate an id per row of this table.
- col: Required scalar node. Specifies a column of the table to be used as the id. You are responsible for back-tics.
- function: Optional scalar node. Specifies a SQL function whose result will be referenced as the value in 'col.' It will be used as the id for the form. If it is not set, then the value under 'col' is really a column of the table.
- writable: Optional scalar node. Defines the write access to the table. If not present or its value cast to false, then the table is not consider to be writable. If its value casts to true, then it is considered writable and the save() method will actually do something.
- fields: Optional parent node. Specifies how the data of the your form is associate to a row of your table. Each child of this node is the name of a field $field of your form.
- $field: Parent node with the following child nodes.
- col: Required scalar node. Specifies a "column" of the table to be used as the id. You are responsible for back-tics.
- function: Optional scalar node. Specifies a SQL function whose result will be referenced as the value in 'col.' If it is not set, then the value under 'col' is really a column of the table.
- type: Required scalar node. The formfield type of this node, e.g. INT, INT_LIST.
- $field: Parent node with the following child nodes.
- parent: Optional parent node. If not present, this form has no parent and getParent() returns 0. It has the following child nodes:
- enabled: Optional scalar node. If set and evaluates to true, it means we should return a non-trivial parent id.
- col: Required scalar node. Specifies a "column" of the table to be used as the id for the parent. You are responsible for back-tics.
- function: Optional scalar node. Specifies a SQL function whose result will be referenced as the value in 'col.' It will be used as the id for the form. If it is not set, then the value under 'col' is really a column of the table.