Form Storage -- Flat Table: Difference between revisions

From IHRIS Wiki
Line 17: Line 17:
***col: Optional scalar node.  Specifies a column of the table to be used as the id. You are responsible for back-tics.
***col: Optional scalar node.  Specifies a column of the table to be used as the id. You are responsible for back-tics.
***function: Optional scalar node.  Optional scalar node.  Specifies a SQL function  whose result will as the value for the field. 'col' takes precedence.
***function: Optional scalar node.  Optional scalar node.  Specifies a SQL function  whose result will as the value for the field. 'col' takes precedence.
***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.
**enabled: Optional scalar node.  If set and evaluates to true, it means we should return a non-trivial parent id.
**col: Optional scalar node.  Specifies a "column" of the table to be used as the id for the parent. You are responsible for back-tics.
**col: Optional 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.  Optional scalar node.  Optional scalar node.  Specifies a SQL function  whose result will as the value for the parent form's id. 'col' takes precedence.
**function: Optional scalar node.  Optional scalar node.  Optional scalar node.  Specifies a SQL function  whose result will as the value for the parent form's id. 'col' takes precedence.

Revision as of 13:18, 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: Optional 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 the id for the form. 'col' takes 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.
  • 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: Optional scalar node. Specifies a column of the table to be used as the id. You are responsible for back-tics.
      • function: Optional scalar node. Optional scalar node. Specifies a SQL function whose result will as the value for the field. 'col' takes precedence.
  • 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: Optional 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. Optional scalar node. Optional scalar node. Specifies a SQL function whose result will as the value for the parent form's id. 'col' takes precedence.