Follow

cml:group - Group Related Form Elements Together

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>

 

⭐ NOTE The following information is supported in Quality Flow and NOT Adap Legacy:

  • You can create multiple nested groups with no maximum depth. However, we recommend limiting nesting to a maximum of three levels for a better user experience for contributors.
  • Logic can be triggered both outside and inside a cml:group.
  • Limitation – Radio Buttons in Groups:
    You cannot trigger logic using radio button elements either to show a group or from within a group.
    • ✅ Recommended alternative: Use cml:select instead.
  • Limitation – cml:text with multiple="true":
    cml:text elements with multiple="true" do not work inside a cml:group.
    • ✅ Recommended alternative: Nest a cml:group and place the cml:text inside that group.

QF Output:

  • When using cml:group with multiple="true", all element outputs within the group appear in a single column, separated by pipes (|).
    For example, if cml:text is inside a cml:group and a contributor creates 3 groups, the output will look like:
    Response 1 | Response 2 | Response 3
  • If a cml:text element is optional or conditionally triggered, and the contributor does not fill it out, the output will include a NULL.
    For example, if the second group was skipped or left blank, the output would be:
    Response 1 | NULL | Response 3=

Example output from the previous code snippet - Within the job:

Screenshot 2025-06-23 at 10.50.37 AM.png

In the output:

Screenshot 2025-06-23 at 10.51.38 AM.png


Was this article helpful?
11 out of 14 found this helpful


Have more questions? Submit a request
Powered by Zendesk