Form Storage -- Flat Table: Difference between revisions

From IHRIS Wiki
No edit summary
No edit summary
Line 1: Line 1:
The ''Flat Table'' storage mechanism allows you to map any flat table that you have in your database into a form.  This is done by specifying:
The ''Flat Table'' storage mechanism allows you to map any flat table that you have in your database into a form.   
*A form name
==Storage Options in Magic Data==
*The table to use
To specify that the form $form has a flat table storage mechanism set by setting
*A way to associate each row of the table to a unique 'id' which will be used as the form's idThis can be done as either:
<center>/modules/forms/forms/$form/storage</center>
**Specifying a column as the 'id' column
to have value '''flat.'''
**Specifying a SQL function that produces the 'id'.
 
*The columns of your table that you want to associate to fields of your form
The options specifying a flat table storage for $form are stored at:
*The FormField type for each of these associated fields
<center>/modules/forms/forms/$form/storage_options/flat</center>
*Any mappings between your fields to fields of another form
It has the following structure:
*Whether you want this table to be read-only or read-write.
*table: Required scalar node. The table to use.  E.g. my_table, `my weird_table`, `some_other_database`.`table`
*An optional parent form.  This includes:
*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:
**The form name of the parent form
*writable: Optional scalar node.  Defines the write access to the tableIf 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.
**A way to specify a parent form 'id' for each row of the table.  This can be done as either:
**field: Optional scalar node.  Specifies a column of the table to be used as the id.
***Specifying a column of the table as the 'parent' column
**function: Optional scalar node.  Specifies a SQL function whose result will be used as the id.
***Specifying a SQL function that produces the parent's forms '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.
***mapped_form:  Optional scalar node.  Defines another form and field in for which this field is the id of that form.
*parent: Optional parent node.  If not present, this form has no parent and getParent() returns 0It 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.

Revision as of 11:47, 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`
  • 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.
      • mapped_form: Optional scalar node. Defines another form and field in for which this field is the id of that form.
  • 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.