Hiding Form Elements
Hiding fields can be accomplished through the system.xml file in the fileLibrary, without any programming required (most of the time).
How It Works
Our JSPs use a <dhv:include /> taglib. These tags allow you to specify in the system.xml file whether or not that form element should be displayed to the user. This is done by conditionally generating the html based on whether it was previously flagged as ignored. Since it a viewable or hidden input on the form, the Action class processing the request will not see any parameter set for that field. This means that the field value will be handled by the Action classes, and it will be assigned a default value (usually null). For that reason, required fields cannot be specified as ignored in system.xml.
Most form elements are wrapped in a <dhv:include /> tag, but some are not even though they are not required. In that case you will need to modify the JSP and add the tag, or submit a bug report specifying the form element that is missing the tag so it can be corrected in the next release.
Procedure
The following procedure outlines the steps involved in hiding fields. Included are snippets on how "DUNS Number"and "SIC Description" could be hidden on the Leads form.
- Back up the system.xml file before making any modifications to it.
- Examine the JSP that you would like to hide fields on
The JSP containing the Leads form is "/contacts/sales_add.jsp"
- Collect the names that appear in the <dhv:include> tags of elements you would like to hide
The following are fragments of the JSP with the elements that will be hidden for this example:
<dhv:include name="organization.dunsNumber" none="true"> <tr> <td nowrap class="formLabel"> <dhv:label name="accounts.accounts_add.duns_number">DUNS Number</dhv:label> </td> <td> <input type="text" size="15" name="dunsNumber" maxlength="30" value="<%= toHtmlValue(ContactDetails.getDunsNumber()) %>" /> </td> </tr> </dhv:include> ... <dhv:include name="organization.sicDescription" none="true"> <tr id="spanSicDescription"> <td nowrap class="formLabel"> <dhv:label name="accounts.accounts_add.sicDescription">SIC Description</dhv:label> </td> <td> <input type="text" size="50" name="sicDescription" maxlength="300" value="<%= toHtmlValue(ContactDetails.getSicDescription()) %>" /> </td> </tr> </dhv:include>
The <dhv:include /> tag has two attributes. The none="true" attribute flags the inner html for conditional rendering. And the name attribute stores the name value that we will need to use in the system.xml file. For this case the values are "organization.dunsNumber" and "organization.sicDescription."
- Update the system.xml file with new params.
If you've haven't modified your system.xml file previously, it will probably have something similar to the following:
<!-- The following fields are set to be hidden or shown from the application --> <!-- depending on whether the application defaults to hiding or showing them --> <config name="system.fields.ignore" enabled="true"> <!-- An unlimited number of parameters can exist under each config --> <param name="pipeline-custom1Integer"/> <!-- <param name="organization.revenue"/> <param name="organization.employees"/> <param name="leads.search.country"/> ... --> </config>
If you can't find it in your system.xml just add a "<config name="system.fields.ignore" enabled="true"> </config>" tag to the file
Note: Any <param /> tags that fall within comments, <!-- ... -->, are not processed.
After adding the params with the names found earlier the snippet will become:
<!-- The following fields are set to be hidden or shown from the application --> <!-- depending on whether the application defaults to hiding or showing them --> <config name="system.fields.ignore" enabled="true"> <!-- An unlimited number of parameters can exist under each config --> <param name="pipeline-custom1Integer"/> <param name="organization.sicDescription"/> <param name="organization.dunsNumber"/> <!-- <param name="organization.revenue"/> <param name="organization.employees"/> <param name="leads.search.country"/> ... --> </config>
- Load the modifications. See Loading system.xml Modifications Without Restart
- Verify and test
Sign in to add your comment.