Defining Forms: Difference between revisions

From IHRIS Wiki
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Esta página describe como definir y personalizar formularios y campos in iHRIS definiéndolos en los [[Configuration (Magic) Data|datos magic ]].    Antes de leer este artículo, por favor lea las  [[Forms and Form Classes|generalidades]] de los formularios y campos para que se familiarice con el modelo de datos de iHRIS.  
This page describes how to define and customize forms and fields in iHRIS by defining them in [[Configuration (Magic) Data|magic data]].    Before reading this article, please read the [[Forms and Form Classes|overview]] of forms and fields to become acquainted with the iHRIS data model.  




==Formularios==
==Forms==
Los formularios son la manera básica de agrupar los datos. Un formulario $form, como 'person', se guarda bajo:
Forms are the basic way to group data. A form $form, such as 'person', is stored under:
  /modules/forms/forms/$form
  /modules/forms/forms/$form
y contiene los siguientes secundarios:
which contains the following children:
*class: Requerido. La clase que implementa la lógica, como la validación par ael formulario. Ejemplo es 'iHRIS_Person'.
*class: Required. The class which implements the logic, such as validation, for the form. Example is 'iHRIS_Person'.
*displayName: OpcionalUn nombre de usuario final para este formulario. Por ejemplo. 'person' podría tener el display name 'Person'
*displayName: OptionalAn end-user name for this form. For example 'person' might have a display name 'Person'
*storage: OpcionalPor defecto esta establecido en 'entry.'  Es el [[Form Storage Mechanisms|mecanismo de almacenamiento]] que debe usar el formularios
*storage: OptionalDefaults to 'entry.'  It is the [[Form Storage Mechanisms|storage mechanism]] that the form should use
*meta: OpcionalUn nodo con muchos secundarios donde se guarda la información acerca de como se muestra este formulario, Los datos aqui se utilizan por la clase del formulario que tiene la función de implementación
*meta: OptionalA node with lots of children where information about displaying this form are saved. The data here is used by the implementing form class
**description: Una descripción de este formularios. Se muestra, por ejemplo, al crear una relación del formulario
**description: A description of this form. It is displayed, for example, when creating a form relationship
**child_forms: Una lista de todos los formularios que son secundarios o hijos de este formulario.
**child_forms: An list of any forms that are child forms of this form.
**child_form_data:  Opcional. Son metadatos asociados con los formularios secundarios. Posiblemete hay un nodo por cada uno de los formularios secundarios.   
**child_form_data:  Optional. Meta data that are associated with child forms. There is possibly a node for each of the child forms.   


Los nodos en los formularios secundarios permiten identificar diferentes agrupaciones para ls formularios secundarios. Por ejemplo el formulario 'training_course' tiene un formulario secundario 'scheduled_training_course.'  Sería conveniente agrupar 'scheduled_training_courses' en ''open'' y ''closed.'' Entonces podemos seleccionar los cursos programados que estan abiertos o cerrados al especificar los limites como se muestra abajoTambién podemos escoger especificar el orden en que se muestran los cursos programados. Por ejemplo:
The nodes in child forms data allow you to specify different groupings for child forms. For example the form 'training_course' has as a child form 'scheduled_training_course.'  We may want to group the 'scheduled_training_courses' into ''open'' and ''closed.'' Then we can select to only display the open or closed scheduled training courses by specifying the limits as belowWe can also chose to specify the order that the scheduled training  courses are displayed in. For example:
  'default'  => Array [
  'default'  => Array [
   'scheduled_training_course' => Array [
   'scheduled_training_course' => Array [
Line 40: Line 40:
   ]  
   ]  
  ]
  ]
Los límites se especifican de acuerdo a [[Limiting Forms|esta]] estructuraEl 'order' es una lista de los campos en los cuales se dividirá la clasificación. En el ejemplo anterior los clasificamos primero por 'start_date' y luego por 'end_date.'  Si quisieramos clasificarlos por un campo en orden descendiente utilizaríamos una - como prefijo.
The limits are specified according to [[Limiting Forms|this]] structureThe 'order' is a list of the fields to sort by. In the above we sort first by 'start_date' and then by 'end_date.'  If we wanted to sort by a field in descending order we would prefix a -.


==Formularios por Componentes==
==Componentized Forms==
Si esta estableciendo una instancia que podrá agregar elementos en iHRIS Manage (o Qualify) algunos de sus formularios serán por components. Esto significa que los datos serán manejados por diferentes localidades (es decir, regions o distritos o incluso departamentos) y usted quiere agregar estos datos decentralizados. Si un formulario es localizado o no, es determinado por el [[Form Storage Mechanisms|mecanismo de almacenamiento del formulario]] que se este utilizando. si un formulario es por componentes, entonces todas las id que hacen referencia a ese formulario tendrán adjunta una '@' y el nombre del componente.
If you are setting up an aggregating instance of iHRIS Manage (or Qualify) some of your forms will be componentized. This means that the data for each of these forms is being managed by distinct localities (e.g. regions or districts or even departments) and you wish to aggregate this de-centralized dataWhether or not a form is localized is determined the [[Form Storage Mechanisms|form storage mechanism]] being used. If a form is componentized, then any id's that reference that form are appended with an '@' and the name of the component.


==Clases de Formularios==
==Form Classes==
Una clase de un formulario $formClass se define bajo:
A form class $formClass is defined under:
  /modules/forms/formClasses/$formClass
  /modules/forms/formClasses/$formClass


Tiene sub-nodos:
It has sub-nodes:
*fields: OpcionalContiene informacion acerca de los campos proporcionados por esta clase
*fields: OptionalContains information about the fields provided by this class
*extends: RequeridoLa clase que extiende la clase de este formulario. Esto debe ser I2CE_Form o una sub-clase del mismo.
*extends: RequiredWhich class this form class extends. This needs to be either I2CE_Form or a subclass of it.


===Creación Dinámica===
===Dynamic Creation===
Si no hay archivo ''$formClass.php'' entonces la clase se crea dinámicamente como:
If there is no file ''$formClass.php'' then the class is created dynamically as:
  class $formClass extends $extendClass {}
  class $formClass extends $extendClass {}
donde $extendClass es el valor bajo el nodo 'extends'.
where $extendClass is the value under the 'extends' node.


===Listas===
===Lists===
La clase del formulario I2CE_List es un formulario especial que permite manejar listas de datos. Cualquier campo mapeado debe tomar valores en un formulario cuya clase que implementa es una sub-clase de I2CE_List.
The form class I2CE_List is a special form which allows you to deal easily with lists of data. Any mapped field should take values in a form whose implementing class is a subclass of I2CE_List.


I2CE_List tiene una sub-clase I2CE_SimpleList cuyo único campo es 'name'.  Algunos ejemplos de listas simples son:
I2CE_List has a subclass I2CE_SimpleList whose only field is 'name'.  Examples of simple lists are:
*género
*gender
*estado_civil
*marital_status
*idioma
*language


===Datos Magic para Listas===
===Magic Data for Lists===
Una lçista es definida por sus datos magic en la clase un formulario, $listClass.  Bajo el nodo de datos data:
A list is defined by its magic data in a form class, $listClass.  Under the magic data node:
  /modules/forms/formClasses/$listClass/meta
  /modules/forms/formClasses/$listClass/meta
de la siguiente manera:
as follows:
*list: Un nodo primario opcional. Cada nodo secundario es un "display" nombrado para esta lista, que puede referenciarse en archivos de plantillas .html.   
*list: An optional parent node. Each child node is a named "display" for this list  which can be referenced in .html templale files.   
**default: Nodo primario opcional. Al mostrar un campo, si no se especifica ningún display, se utilizan los datos bajo en nodo "default" para determinarlo.
**default: Optional parent node. When displaying a field, if no display is specified, the data under the node "default" is used to determine the display.
***display_string:  La cadena de estilo de display printf que se utiliza para mostrar esta forma en una lista o árbol. Por defecto es "%s".  <p/>Las sustituciones printf están de acuerdo a [http://www.php.net/manual/en/function.sprintf.php esto].  Tome en cuenta que si hay más de un campo a sustituir, debe usar referencias/argumentos para que los traductores puedan manejar esto de manera adecuada. Así que en vez de "%s %s" usaría "%1$s %2$s"
***display_string:  The printf style display string used to display this form in a drop down or tree select. Defaults to "%s".  <p/>The printf substitutions is according to [http://www.php.net/manual/en/function.sprintf.php this].  Please note that if there is more than one field to be substituted, you should use references/arguments so that translators can handle this appropriately.   So instead of "%s %s" you would use "%1$s %2$s"
***display_args: Los campos que se pasan a la display_string para Impresión. Por defecto tiene un secundario con clave 0 y valor "name" (aunque puede que este campo no exista)
***display_args: The fields which are passed to display_string to be printed. Defaults to having one child with key 0 and value "name" (although this field may not exist!)
****0:  Nodo escalarEl nombre de un campo en este formulario.
****0:  Scalar nodeThe name of a field in this form.
****1:  Nodo escalarEl nombre de un campo en este formulario.
****1:  Scalar nodeThe name of a field in this form.
****2:  Nodo escalarEl nombre de un campo en este formulario.
****2:  Scalar nodeThe name of a field in this form.
****...:  Debe haber el mismo número de secundarios como de sustituciones referenciadas en display_string
****...:  There should be the same number of children as there are referenced substitutions in display_string
***sort_fields:  Nodo primario opcional. El orden que debe aplicarse al mostrar esta lista. Los secundarios son nodos escalares con claves enteras y valores con el onmbre del campo. Por defecto tiene un secundario con clave 0 y valor "name" (aunque puede que este campo no exista)
***sort_fields:  Optional parent node. The ordering that should be applied when displaying this listChildren are scalar nodes with keys integers and values the name of the field. Defaults to having one child with key 0 and value "name" (although this field may not exist!)
**$display1: Nodo primario opcionalLa estructura es la misma que la del anterior "por defecto" .
**$display1: Optional parent nodeStructure is the same as the "default" above.
**$display2: Nodo primario opcionalLa estructura es la misma que la del anterior "por defecto" .
**$display2: Optional parent nodeStructure is the same as the "default" above.


==Campos==
==Fields==
Información acerca de [[Form Fields]]
Information on [[Form Fields]]


[[Category:Technical Overview]][[Category:Forms]][[Category:Review2013]][[Category:Needs Intro]]
[[Category:Forms]][[Category:Review2013]]

Latest revision as of 12:48, 8 November 2013

This page describes how to define and customize forms and fields in iHRIS by defining them in magic data. Before reading this article, please read the overview of forms and fields to become acquainted with the iHRIS data model.


Forms

Forms are the basic way to group data. A form $form, such as 'person', is stored under:

/modules/forms/forms/$form

which contains the following children:

  • class: Required. The class which implements the logic, such as validation, for the form. Example is 'iHRIS_Person'.
  • displayName: Optional. An end-user name for this form. For example 'person' might have a display name 'Person'
  • storage: Optional. Defaults to 'entry.' It is the storage mechanism that the form should use
  • meta: Optional. A node with lots of children where information about displaying this form are saved. The data here is used by the implementing form class
    • description: A description of this form. It is displayed, for example, when creating a form relationship
    • child_forms: An list of any forms that are child forms of this form.
    • child_form_data: Optional. Meta data that are associated with child forms. There is possibly a node for each of the child forms.

The nodes in child forms data allow you to specify different groupings for child forms. For example the form 'training_course' has as a child form 'scheduled_training_course.' We may want to group the 'scheduled_training_courses' into open and closed. Then we can select to only display the open or closed scheduled training courses by specifying the limits as below. We can also chose to specify the order that the scheduled training courses are displayed in. For example:

'default'  => Array [
 'scheduled_training_course' => Array [
  'order' => 'start_date,end_date' 
 ] 
]
'open' => Array [
 'scheduled_training_course' => Array [
  'limits' => Array [
    'operator' => 'FIELD_LIMIT'
    'field' => 'start_date'
    'style' => 'greaterthan_now'
  ]
  'order' => 'start_date,end_date'
 ] 
]
'closed' => Array [
  'scheduled_training_course' => Array [
   'limits' => Array [
     'operator' => 'FIELD_LIMIT'
     'field' => 'start_date'
     'style' => 'lessthan_now'
   ]
   'order' => 'start_date,end_date'
 ] 
]

The limits are specified according to this structure. The 'order' is a list of the fields to sort by. In the above we sort first by 'start_date' and then by 'end_date.' If we wanted to sort by a field in descending order we would prefix a -.

Componentized Forms

If you are setting up an aggregating instance of iHRIS Manage (or Qualify) some of your forms will be componentized. This means that the data for each of these forms is being managed by distinct localities (e.g. regions or districts or even departments) and you wish to aggregate this de-centralized data. Whether or not a form is localized is determined the form storage mechanism being used. If a form is componentized, then any id's that reference that form are appended with an '@' and the name of the component.

Form Classes

A form class $formClass is defined under:

/modules/forms/formClasses/$formClass

It has sub-nodes:

  • fields: Optional. Contains information about the fields provided by this class
  • extends: Required. Which class this form class extends. This needs to be either I2CE_Form or a subclass of it.

Dynamic Creation

If there is no file $formClass.php then the class is created dynamically as:

class $formClass extends $extendClass {}

where $extendClass is the value under the 'extends' node.

Lists

The form class I2CE_List is a special form which allows you to deal easily with lists of data. Any mapped field should take values in a form whose implementing class is a subclass of I2CE_List.

I2CE_List has a subclass I2CE_SimpleList whose only field is 'name'. Examples of simple lists are:

  • gender
  • marital_status
  • language

Magic Data for Lists

A list is defined by its magic data in a form class, $listClass. Under the magic data node:

/modules/forms/formClasses/$listClass/meta

as follows:

  • list: An optional parent node. Each child node is a named "display" for this list which can be referenced in .html templale files.
    • default: Optional parent node. When displaying a field, if no display is specified, the data under the node "default" is used to determine the display.
      • display_string: The printf style display string used to display this form in a drop down or tree select. Defaults to "%s".

        The printf substitutions is according to this. Please note that if there is more than one field to be substituted, you should use references/arguments so that translators can handle this appropriately. So instead of "%s %s" you would use "%1$s %2$s"

      • display_args: The fields which are passed to display_string to be printed. Defaults to having one child with key 0 and value "name" (although this field may not exist!)
        • 0: Scalar node. The name of a field in this form.
        • 1: Scalar node. The name of a field in this form.
        • 2: Scalar node. The name of a field in this form.
        • ...: There should be the same number of children as there are referenced substitutions in display_string
      • sort_fields: Optional parent node. The ordering that should be applied when displaying this list. Children are scalar nodes with keys integers and values the name of the field. Defaults to having one child with key 0 and value "name" (although this field may not exist!)
    • $display1: Optional parent node. Structure is the same as the "default" above.
    • $display2: Optional parent node. Structure is the same as the "default" above.

Fields

Information on Form Fields