Forms and Form Classes: Difference between revisions

From IHRIS Wiki
No edit summary
Line 1: Line 1:
Los registros se guardan en el Intrahealth Informatics Core Engine (I2CE) en formularios que consisten de una colección de campos. Se puede pensar en un formulario como una tabla en una base de datos y un campo como una columna de esa tabla.   
Records are stored in the Intrahealth Informatics Core Engine (I2CE) in forms which consist of a collection fields.   You may roughly think of a form as table in a database and a field as a column of that table.   


La lógica de un formulario se maneja por medio de una ''Form Class'' que extiende '''I2CE_Form.'''  La lógica de un campo se maneja por medio de una clase que extiende ''I2CE_FormField.''
The logic of a form is handled by a ''Form Class'' which extends '''I2CE_Form.'''  The logic of a field is handled by a class extending ''I2CE_FormField.''




==Referencias en Plantillas==
==Referencing in Templates==
El sistema de [[Pages and Templates|templating]] permite la fácil referencia de los datos duardatos en un formulario en una plantilla html. Por ejemplo para hacer referencia al primer nombre de una persona puede utilizar:
The [[Pages and Templates|templating]] system allows easy reference to data stored in a form in an html template. For example to reference a person's firstname you can use:
  <nowiki><p  id='my_person'>You are looking at <span type='form' name='person:firstname'/> <span type='form' name='person:surname'/>!</p></nowiki>
  <nowiki><p  id='my_person'>You are looking at <span type='form' name='person:firstname'/> <span type='form' name='person:surname'/>!</p></nowiki>
Se convertiría en
Would be  turned into
  <nowiki><p id='my_person'>You are looking at Joe Smith!</p></nowiki>
  <nowiki><p id='my_person'>You are looking at Joe Smith!</p></nowiki>
si hubiera un formulario de 'person' en el nodo o arriba de este con id 'my_person'.  El html se modifica por medio del sistema de plantillas. En la versión 3.1, esto se realiza con el método  'processForms()' de la clase del modulo del ''forms'' , ''I2CE_Module_Forms'', por medio de [[Module Structure#Hooked Methods|hooking]] en los 'process_templatedata_FORM' definidos en I2CE_Module_TemplateData.
if there was a 'person' form set at or above the node with id 'my_person'.  The html is modified by the templating system. In version 3.1, this is done by the 'processForms()' method of the ''forms'' module class, ''I2CE_Module_Forms'', by [[Module Structure#Hooked Methods|hooking]] into the hook 'process_templatedata_FORM' defined in I2CE_Module_TemplateData.


Es responsabilidad de la página asegurarse de que el formulario adecuado se asigne al nodo adecuado en la plantilla.
It is the responsibility of the page to make sure the appropriate form is assigned to the appropriate node in the template.


==Formularios y sus Clases==
==Forms and Their Classes==


Un formulario $form esta vinculado a una clase de formulario al especificar los datos en ''/modules/forms/forms/$form/class''
A form $form is linked to a form classes by specifying the data at ''/modules/forms/forms/$form/class''
para ser el nombre de la clase del formulario.  For ejemplo:
to be the name of the form class.  For example:
  I2CE::getConfig()->modules->forms->person->class = 'I2CE_ManagePerson';
  I2CE::getConfig()->modules->forms->person->class = 'I2CE_ManagePerson';


Las clases pueden o no existir como archivosSi hay datos lógicos que un formuulario debe desarrollar, por ejemplo existirá en su métodos ''validate()'' y ''save()'' . De lo contrario, existen virtualmenteA partir de la versión 3.2 tales como una clase virtual se generan automaticamente utilizando el método ''__autoload()'' .
The classes may or may not exist as filesIf there is logic that a form needs to perform, for instance on its ''validate()'' and ''save()'' methods it will exist. Otherwise, they exist virtuallyStarting in version 3.2 such a virtual class is generated 'on-the-fly' by making use of the ''__autoload()'' method.


==Los Campos y sus Clases==
==Fields and Their Clases==
Todos los campos de un formulario tiene un nombre y un tipo. El nombre de los campos es como se referencia el campo por el formulario como una variable pública utilizando los métodos ''__get()'' y ''__set()'' .  Por ejemplo:
All fields of a form have a name and a type. The name of the fields is how the field is referenced by the form as a public variable by using the ''__get()'' and ''__set()'' methodsFor example:
  if ($person instanceof I2CE_Person)  {
  if ($person instanceof I2CE_Person)  {
   echo "$person->firstname . "\n";
   echo "$person->firstname . "\n";
  }
  }


Los tipos afectan como se guardan los datos en la base de datos y como se muestran los datos y como se introducen en el sistemaLa siguiente es una lista de tipos comunes:
The types effect how the data is stored in the database and how the data is displayed and entered in the systemThe following are a list of common types:
*BOOL  Un valor Boolean verdadero/falso
*BOOL  A boolean True/False value
*CURRENCY Un valor de moneda
*CURRENCY A currency value
*DATE_HMS Una hora en horas, minutos, segundos
*DATE_HMS A hour, minute, second time
*DATE_MD Una fecha de día y mes
*DATE_MD A month and date
*DATE_TIME Una hora
*DATE_TIME A time
*DATE_Y Un año
*DATE_Y A year
*DATE_YMD Un año, mes y fecha
*DATE_YMD A year, month and date
*INT Un valor entero
*INT An integer value
*INT_LIST Una lista de enteros
*INT_LIST A list of integers
*INT_GENEREATE Un entero que incrementa automaticamente
*INT_GENEREATE An integer which automatically increments
*STRING_LINE Una línea de texto
*STRING_LINE A line of text
*STRING_MLINE Varias líneas de texto
*STRING_MLINE Several lines of text
*STRING_PASS Una contraseña
*STRING_PASS A password
*STRING_TEXT Mucho texto
*STRING_TEXT A lot of text
*YESNO Un valor Si/No
*YESNO A Yes/No value
Un $type se maneja por el I2CE_FormField_$type de clase
A $type is handled by the class I2CE_FormField_$type


=Los formularios y sus Campos=
=Forms and Their Fields=
La estructura de los formularios, sus clases y campos y donde están definidos puede encontrarse fácilmente en:
The structure of forms, their classes and fields and where they are defined in can be easily browsed at:
*[http://open.intrahealth.org/ihris-docs/form_documentor/ Form and Field Browser] Aplica para la version de desarrollo 3.2
*[http://open.intrahealth.org/ihris-docs/form_documentor/ Form and Field Browser] Applies to development version 3.2


=Como se Guardan los Datos=
=How the Data is Stored=
Aunque puede pensar en un formulario como una tabla en una base de datos, no es tan así.
Although you may loosely think of a form as being a table in the database, it is not quite so.
==Versión 3.1==
==Version 3.1==
En la versión 3.1 todos los datos guardados en los formularios se guardan en las tablas de 'entry' y 'last_entry' . Estas tablas mantienen un historial de los cambios realizados a los datos en base al usuario que realize los cambios, el tipo de cambio y la hora del cambio La table de 'entry' tiene toda la historia mientras que la tabla de 'last_entry' solamente contiene los cambios más recientes realizados a un campo.
In version 3.1 all data stored in forms is stored in the 'entry' and 'last_entry' tables. These tables keep a history of the changes made to the data based on the user that changed the data, the type of the change, and the time of the changeThe 'entry' table has all of the history, while the 'last_entry' table only contains the most recent changes to a field.




==Versión 3.2==
==Version 3.2==
A partir de esta versión estamos múltiples mecanismos de almacenamiento para un formulario. El mecanismo de almacenamiento por defecto seguirá siendo a través de las tablas de 'entry' y 'last_entry' tabla.   
Starting in this version we are enabling multiple storage mechanisms for a form. The default storage mechanism will still be through the 'entry' and 'last_entry' table.   


Además activaremos el almacenamiento para tablas de bases de datos específicas para permitir al administrador que incorpore facilmente Fuentes de datos externas en la utilidad de los Informes Personalizados. Esto sera de sólo lectura o de lectura y escritura según el usuario especificado.
In addition we will enable storage to specified database tables to allow the administrator to easily incorporate outside data sources into the Custom Reporting utility. This will be either read-only or read-write as the user specified.


También permitimos el almacenamiento en Datos Magic. Esto tiene la función principal de enumerar datos que un adminstrador desea mantener centralizados en un modulo y luedo enviar a oficinas regionals. Además, las listas almacenadas en Datos Magic serán localizables.
We also allow storage in Magic Data. This is primarily intended for list data that a administrator wishes to maintain centrally in a module and then ship out to regional offices. In addition, the lists stored in Magic Data will be localizable.
[[Category:Technical Overview]][[Category:Forms]][[Category:Classes]][[Category:Review2013]][[Category:Archived Pages]][[Category:Bad Links]]
[[Category:Technical Overview]][[Category:Forms]][[Category:Classes]][[Category:Review2013]][[Category:Archived Pages]][[Category:Bad Links]]

Revision as of 21:04, 30 September 2013

Records are stored in the Intrahealth Informatics Core Engine (I2CE) in forms which consist of a collection fields. You may roughly think of a form as table in a database and a field as a column of that table.

The logic of a form is handled by a Form Class which extends I2CE_Form. The logic of a field is handled by a class extending I2CE_FormField.


Referencing in Templates

The templating system allows easy reference to data stored in a form in an html template. For example to reference a person's firstname you can use:

<p  id='my_person'>You are looking at <span type='form' name='person:firstname'/> <span type='form' name='person:surname'/>!</p>

Would be turned into

<p id='my_person'>You are looking at Joe Smith!</p>

if there was a 'person' form set at or above the node with id 'my_person'. The html is modified by the templating system. In version 3.1, this is done by the 'processForms()' method of the forms module class, I2CE_Module_Forms, by hooking into the hook 'process_templatedata_FORM' defined in I2CE_Module_TemplateData.

It is the responsibility of the page to make sure the appropriate form is assigned to the appropriate node in the template.

Forms and Their Classes

A form $form is linked to a form classes by specifying the data at /modules/forms/forms/$form/class to be the name of the form class. For example:

I2CE::getConfig()->modules->forms->person->class = 'I2CE_ManagePerson';

The classes may or may not exist as files. If there is logic that a form needs to perform, for instance on its validate() and save() methods it will exist. Otherwise, they exist virtually. Starting in version 3.2 such a virtual class is generated 'on-the-fly' by making use of the __autoload() method.

Fields and Their Clases

All fields of a form have a name and a type. The name of the fields is how the field is referenced by the form as a public variable by using the __get() and __set() methods. For example:

if ($person instanceof I2CE_Person)  {
 echo "$person->firstname . "\n";
}

The types effect how the data is stored in the database and how the data is displayed and entered in the system. The following are a list of common types:

  • BOOL A boolean True/False value
  • CURRENCY A currency value
  • DATE_HMS A hour, minute, second time
  • DATE_MD A month and date
  • DATE_TIME A time
  • DATE_Y A year
  • DATE_YMD A year, month and date
  • INT An integer value
  • INT_LIST A list of integers
  • INT_GENEREATE An integer which automatically increments
  • STRING_LINE A line of text
  • STRING_MLINE Several lines of text
  • STRING_PASS A password
  • STRING_TEXT A lot of text
  • YESNO A Yes/No value

A $type is handled by the class I2CE_FormField_$type

Forms and Their Fields

The structure of forms, their classes and fields and where they are defined in can be easily browsed at:

How the Data is Stored

Although you may loosely think of a form as being a table in the database, it is not quite so.

Version 3.1

In version 3.1 all data stored in forms is stored in the 'entry' and 'last_entry' tables. These tables keep a history of the changes made to the data based on the user that changed the data, the type of the change, and the time of the change. The 'entry' table has all of the history, while the 'last_entry' table only contains the most recent changes to a field.


Version 3.2

Starting in this version we are enabling multiple storage mechanisms for a form. The default storage mechanism will still be through the 'entry' and 'last_entry' table.

In addition we will enable storage to specified database tables to allow the administrator to easily incorporate outside data sources into the Custom Reporting utility. This will be either read-only or read-write as the user specified.

We also allow storage in Magic Data. This is primarily intended for list data that a administrator wishes to maintain centrally in a module and then ship out to regional offices. In addition, the lists stored in Magic Data will be localizable.