Creating a New Form Field: Difference between revisions

From IHRIS Wiki
(Created page with 'This tutorial applies to version 4.0 of the iHRIS Suite. In this tutorial, we will create new form field data type. This form field will be a one line string which is capitaliz…')
 
Line 6: Line 6:
In one of your module directories (e.g. your site's modules directory) do the following:
In one of your module directories (e.g. your site's modules directory) do the following:
  mkdir CapField
  mkdir CapField
mkdir CapField/templates
mkdir CapField/lib
  gedit CapField/CapField.xml
  gedit CapField/CapField.xml
and add in the following lines:
and add in the following lines:
Line 35: Line 37:
   </configuratioGroup>
   </configuratioGroup>
<I2CEConfiguration>
<I2CEConfiguration>
</source>  
</source>
 
 


==I2CE_Form_Field_STRING_CAP==
==I2CE_Form_Field_STRING_CAP==

Revision as of 10:10, 14 September 2009

This tutorial applies to version 4.0 of the iHRIS Suite.

In this tutorial, we will create new form field data type. This form field will be a one line string which is capitalized. The capitalization will be enforced on the server-side as well as the client-side via java-script. We will wrap all of this into a module, CapField so that it can be shared easily.

Creating the Module

In one of your module directories (e.g. your site's modules directory) do the following:

mkdir CapField
mkdir CapField/templates
mkdir CapField/lib
gedit CapField/CapField.xml

and add in the following lines: <source lang='xml'>

<?xml version="1.0"?>       

<!DOCTYPE I2CEConfiguration SYSTEM "I2CE_Configuration.dtd"> <I2CEConfiguration name='CapField'>

 <metadata>
   <displayName>Capitalized Field</displayName>   
   <category>System Component</category>
   <description>Provides an always capitalized field</description>
   <creator>Intrahealth Informatics</creator>
   <email>hris@capacityproject.org</email>
   <version>4.0.0</version> 
   <requirement name='i2ce'>
     <atleast version='4.0'/>
     <lessThan version='4.1'/>
   </requirement>
   <priority>200</priority>
   <path name='classes'>
     <value>./lib</value>
   </path>
   <path name='templates'>
     <value>./templates</value>
   </path>
 </metadata>
 <configurationGroup name='CapField' path='/'>
 </configuratioGroup>

<I2CEConfiguration> </source>

I2CE_Form_Field_STRING_CAP

Making the form field available

Javascript

iHRIS uses version 1.2 of the mootools javascript library. Mootools has a handy capitalization function that we will incorporate into our form field so that on a "blur" the input element will capitalize. There are two parts two this: changing the html template file, and linking in the mootools library when it is needed.

Modifying the Template

Linking in Mootools