Customizing Form and Field Headers: Difference between revisions

From IHRIS Wiki
Line 3: Line 3:
==Field Headers==
==Field Headers==
You can customize the headers for a form field by updating the magic data associated with the headers.  You can do this through the magic data browser, but the best way is to make the change in a module for your site or in your site configuration file.  Headers are at the magic data location:  /modules/forms/formClasses/'''$formClass'''/fields/'''$field'''/headers/'''$headerType'''
You can customize the headers for a form field by updating the magic data associated with the headers.  You can do this through the magic data browser, but the best way is to make the change in a module for your site or in your site configuration file.  Headers are at the magic data location:  /modules/forms/formClasses/'''$formClass'''/fields/'''$field'''/headers/'''$headerType'''
In most cases you'll use the "default" as the '''$headerType'''.  If you want to have multiple headers, then change the header type and in the template that is displaying your field set the '''$headerType''' as the value for the showhead attribute.
<source lang="html4strict">
<span type="form" name="$form:$field" showhead="$headerType"></span>
</source>
Replace $form, $field and $headerType with the appropriate values for your template.  For example:
<source lang="html4strict">
<span type="form" name="country:name" showhead="my_header"></span>
</source>


In your site or module configuration file, you can change the headers by adding the following lines:
In your site or module configuration file, you can change the headers by adding the following lines:
<source lang="xml">
<source lang="xml">
<configuration name="custom_headers" path="/modules/forms/formClasses/$formClass/fields/$field/headers/default" locale="en_US">
<configuration name="custom_headers" path="/modules/forms/formClasses/$formClass/fields/$field/headers/$headerType" locale="en_US">
   <value>$newHeader</value>
   <value>$newHeader</value>
</configuration>
</configuration>
Line 24: Line 15:
   <value>State</value>
   <value>State</value>
</configuration>
</configuration>
</source>
In most cases you'll use the "default" as the '''$headerType'''.  If you want to have multiple headers, then change the header type and in the template that is displaying your field set the '''$headerType''' as the value for the showhead attribute.
<source lang="html4strict">
<span type="form" name="$form:$field" showhead="$headerType"></span>
</source>
Replace $form, $field and $headerType with the appropriate values for your template.  For example:
<source lang="html4strict">
<span type="form" name="country:name" showhead="my_header"></span>
</source>
</source>



Revision as of 16:17, 26 May 2010


Field Headers

You can customize the headers for a form field by updating the magic data associated with the headers. You can do this through the magic data browser, but the best way is to make the change in a module for your site or in your site configuration file. Headers are at the magic data location: /modules/forms/formClasses/$formClass/fields/$field/headers/$headerType

In your site or module configuration file, you can change the headers by adding the following lines: <source lang="xml"> <configuration name="custom_headers" path="/modules/forms/formClasses/$formClass/fields/$field/headers/$headerType" locale="en_US">

 <value>$newHeader</value>

</configuration> </source> For example, to change the header of the region field in districts you can do this: <source lang="xml"> <configuration name="region_header" path="/modules/forms/formClasses/iHRIS_District/fields/region/headers/default" locale="en_US">

 <value>State</value>

</configuration> </source>

In most cases you'll use the "default" as the $headerType. If you want to have multiple headers, then change the header type and in the template that is displaying your field set the $headerType as the value for the showhead attribute. <source lang="html4strict"> </source> Replace $form, $field and $headerType with the appropriate values for your template. For example: <source lang="html4strict"> </source>

Form Display Names

You may also want to change the display name associated with a form. You can do this by changing the magic data at /modules/forms/forms/$form/display. You can make this change in your site or module configuration file.

<source lang="xml"> <configuration name="form_display" path="/modules/forms/forms/$form/display" locale="en_US">

 <value>$newHeader</value>

</configuration> </source> For example, to change the display name for region to be State: <source lang="xml"> <configuration name="region_display" path="/modules/forms/forms/region/display" locale="en_US">

 <value>State</value>

</configuration> </source>

Some templates (like lists.html) may refer to the name in the template directly. You'll also need to modify this template to use the name you wish when linking to editing the database list for that form.

Geography Example

Here's a complete example that will change the names of the levels of geography to be Country/State/Council/Town or City. Country will stay the same, region will become State, district will become Council and county will be come Town or City.

<source lang="xml"> <configurationGroup name="forms_module" path="/modules/forms">

 <configurationGroup name="forms">
   <configuration name="region_display" path="region/display" locale="en_US">
     <value>State</value>
   </configuration>
   <configuration name="district_display" path="district/display" locale="en_US">
     <value>Council</value>
   </configuration>
   <configuration name="region_display" path="county/display" locale="en_US">
     <value>Town or City</value>
   </configuration>    
 </configurationGroup>
 <configurationGroup name="formClasses">
   <configuration name="district_region_header" path="iHRIS_District/fields/region/headers/default" locale="en_US">
     <value>State</value>
   </configuration>
   <configuration name="country_district_header" path="iHRIS_County/fields/district/headers/default" locale="en_US">
     <value>Council</value>
   </configuration>
 </configurationGroup>

</configurationGroup>

</source>