cml:group
Group related questions together so that they can easily be hidden or shown with CML logic without having to write only-if attributes for every field.
<cml:radios label="What is the sentiment of this tweet?" name="sentiment" >
<cml:radio label="Positive"/>
<cml:radio label="Neutral"/>
<cml:radio label="Negative"/>
</cml:radios>
<cml:group only-if="sentiment:[0]">
<cml:text label="How many likes does this tweet have?:" name ="likes" instructions="Enter amount above" />
<cml:checkboxes label="Does this tweet mention any of the following sports?" name="sports" validates="required" >
<cml:checkbox label="Football" />
<cml:checkbox label="Baseball" />
<cml:checkbox label="Basketball" />
</cml:checkboxes>
</cml:group>
In the above example, both the cml:text
and cml:checkboxes
fields will be hidden/shown depending on whether the sentiment field passes the cml:radios
logic.
Allowing multiple answers for cml:group
There may be occasions where multiple answers are needed for elements with cml:group
. Using ‘multiple=true’ can help keep your UI looking clean and allow for as many answers as you’d like:
<cml:checkbox label="Does the tweet have any names mentioned?" validates="required" name="tweet_names" />
<cml:group only-if="!tweet_names:unchecked" multiple="true">
<cml:text label="Enter name:" name="names" />
</cml:group>