Reference Field: Difference between revisions

From IHRIS Wiki
Line 21: Line 21:
==HTML Template==
==HTML Template==
To display the default  
To display the default  
<source lang='html'>
<source lang='xml'>
   <span type='form' name='$form+$field'/>
   <span type='form' name='$form+$field'/>
</source>
</source>


To select another display, $display:
To select another display, $display:
<source lang='html'>
<source lang='xml'>
   <span type='form' name='$form+$field' show='$display'/>
   <span type='form' name='$form+$field' show='$display'/>
</source>
</source>

Revision as of 11:41, 11 February 2011

This describe the magic data structure used for defining a REFERENCE field. These options all live under

/modules/forms/formClasses/$formClass/fields/$field

for the given form class $formClass and field name $field.


Magic Data Structure

  • meta: required parent node.
    • display: required parent node. names of sub-nodes are the names of the forms that this field can reference.
      • $refForm: required parent node. The name of the node, $refForm, is a form that this field can reference.
        • default: required parent node. The default display for the referenced form
          • printf: required (translatable) scalar node. A string which will get passed to printf to display the node. Example is "%s %s" which contains two substitutions
          • printf_args: required parent node: Sub-nodes should be ordered integers. requires 0..n sub-nodes if the printf contains (n+1) substutions.
            • 0: required scalar node the name of the first field whose display value is passed to printf
            • 1: requried scalar node the name of the next field whose display value is passed to printf
            • ...
            • n: requried scalar node the name of the last field whose display value is passed to printf
        • $display: optional parent node. Another named display for this field. Sub-nodes are exactly the same as those defined for default

A REFERENCE field is only considered valid if the form it references, $refForm, is one who has a node under display.

HTML Template

To display the default <source lang='xml'>

  

</source>

To select another display, $display: <source lang='xml'>

  

</source>

Editing the Field Value

For the moment, the field is not editable. Rather its value should be set by a page's logic.

At a later point, we can make the value set via the selection of a primary form (or other?) in from a report.