Adding Datasets for Form Assets
Some form asset elements - those with multiple answer options such as radio buttons and checkboxes - can make use of datasets to auto-create the list of answer items. Enter the dataset in the "Advanced" tab of the element, and the form pulls the information in the dataset. Some datasets come predefined, but you can also make your own.
A conditional defined in the XSL creates the dataset based on the use of the Advanced field in the form element and the dataset named within. In the XSL, the name of the dataset to use gets passed to the XSL with $adv. The XSL does a choose test to return the correct dataset.
Another dataset can be added to the existing XSL as another "when" condition. The "when" condition is set off with double quotes, so the dataset name is included within single quotes.
There are two methods for adding a new dataset to your XSL; which one you use depends on whether your implementation pulls in global XSL files from our repository. An easy way to check if you use the global XSL is to run a find on your resources folder for <xsl:import href="/var/staging/OMNI-INF/
(or <xsl:import href="/var/staging/[skin]/OMNI-INF/
if you share templates across an account). If one of your XSL files (usually common.xsl
) contains this statement, then your implementation uses the global XSL.
No Global XSLLink to this section
- Navigate to Content > Pages.
- Find the
datasets.xsl
file (typically located in_resources/xsl/_shared
). - Add your new dataset to the list. As an example, use the following dataset called "shakespeare":
The name of the dataset (<xsl:when test="ou:get-adv($adv,'dataset') = 'shakespeare'"> Titus Andronicus,Taming of the Shrew,Henry IV Part 1,Henry IV Part 2,Henry V,Much Ado About Nothing,Twelfth Night,Othello,Hamlet </xsl:when>
shakespeare
) and the values entered can be changed to whatever you want. Each item should be separated by a comma, with no spaces in between. Spaces can be used within an item, but character entities should not. For example, instead of an ampersand (&) the HTML entity should be used (&) and instead of a quote mark ('), the " entity should be used. - Save the XSL file. It doesn't need to be published.
With Global XSLLink to this section
- Navigate toContent>Pages.
- Find
/_resources/xsl/shared/forms.xsl
and open the source code editor. - Paste the following code at line 312:
<xsl:template name="customer-custom-datasets"> <xsl:param name="dataset-name" /> <xsl:choose> <xsl:when test="$dataset-name = 'custom-1'">option1,option2</xsl:when> <xsl:when test="$dataset-name = 'custom-2'">opt1,opt2</xsl:when> <xsl:otherwise><xsl:value-of select=\"'************************************************************************************, Dataset used that is not configured. Please Check Configuration before publishing..., ************************************************************************************'\" /> </xsl:otherwise> </xsl:choose> </xsl:template>
- Replace
'custom-1'
with the name of your new dataset. - Add in the dataset values between the
>
and<
characters, comma-separated with no spaces in between, and in the order you want. Spaces can be used within an item, but character entities should not. For example, instead of an ampersand (&) the HTML entity should be used (&) and instead of a quote mark ('), the " entity should be used. - For each new dataset, copy the
<xsl:when>
statement and adjust as needed. - Save the XSL file. It doesn't need to be published.
Adding a Dataset to a FormLink to this section
To add a custom dataset to a form asset:
- Navigate to Content > Assets.
- Either edit an existing form asset or create a new one.
- Add one of the following form elements that supports datasets:
- Radio Buttons
- Checkboxes
- Dropdown
- Multi-select
- In the "Advanced" field, enter
dataset=####;
, where #### is the name of your custom dataset. - Save and publish the asset.