Form Storage -- Flat Table: Difference between revisions

From IHRIS Wiki
Line 9: Line 9:
It has the following structure:
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.
*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.  At least one of the following must be specified, with ''field'' taking precedence:
*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 ''col'' taking precedence:
**field: Optional scalar node.  Specifies a column of the table to be used as the id.
**col: 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.
**function: Optional scalar node.  Specifies a SQL function whose result will be used as the id.
*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.
*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.
*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.  At least one of 'field' or 'function' need to be specified with 'field' taking precedence:
**$field:  Parent node with the following child nodes.  At least one of 'col' or 'function' need to be specified with 'col' taking precedence:
***field: Optional scalar node.  Specifies a column of the table to be used as the id.
***col: 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.
***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.
***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:
**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:
**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 'col' taking precedence:
**field: Optional scalar node.  Specifies a column of the table to be used as the id for the parent.
**col: 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.
**function: Optional scalar node.  Specifies a SQL function whose result will be used as the id.

Revision as of 12:33, 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. At least one of the following must be specified, with col taking precedence:
    • col: 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.
  • 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. At least one of 'col' or 'function' need to be specified with 'col' taking precedence:
      • col: 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.
  • 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 'col' taking precedence:
    • col: 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.