Form Storage -- Flat Table
From IHRIS Wiki
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`
- id: Required parent node. The data defining how to associate an id per row of this table. At least one of the following must be specified, with field taking precedence:
- 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.
- field: Optional scalar node. Specifies a column of the table to be used as the id.
- function: Optional scalar node. Specifies a SQL function whose result will be used as the id.
- columns: Optional parent node. The columns of your table that you want to associate to fields of your form. Each child of this node is the name of a field $field of your form.
- $field: Parent node with the following child nodes. At least one of 'field' or 'function' need to be specified with 'field' taking precedence:
- field: Optional scalar node. Specifies a column of the table to be used as the id.
- function: Optional scalar node. Specifies a SQL function whose result will be used as the id.
- type: Required scalar node. The formfield type of this node, e.g. INT, INT_LIST.
- $field: Parent node with the following child nodes. At least one of 'field' or 'function' need to be specified with 'field' taking precedence:
- parent: Optional parent node. If not present, this form has no parent and getParent() returns 0. It has the following child nodes:
- form: Optional scalar valued. If present and set this is the name of parent form is considered to have a parent. At least on of the following needs to be specified, with field taking precedence:
- field: Optional scalar node. Specifies a column of the table to be used as the id for the parent.
- function: Optional scalar node. Specifies a SQL function whose result will be used as the id.