Repeat group from checkbox question

How can I set up a repeat group where it repeats for each of the choices selected in a checkbox question that precedes it?

This is definitely possible, but takes a bit of a two-part pattern to build out.

The key thing to model about the structure of the interaction is that the form can't dynamically increase and reduce the set of repeats as the checkbox answers change, so instead you'll need to "unroll" all of the potential answers to the repeat, and then use a conditional group inside of each repeat element to decide whether to display its contents based on the answer to the checkbox question.

The basic structure of how to build this is to unroll the repeat with a model iteration over a lookup table (which will create one repeat element per table entry), and then add a single top-level group to the repeat which all of the questions are placed into which references the checkbox question in its display condition.

Thanks! Although it is not as simple as I had hoped :slight_smile:

Yeah, unfortunately it gets a little tricky due to the way that the declarative logic works, but that pattern also makes it clearer how the form should, say, react when items are chosen, responded too, and then the original list changes.

If it's helpful here's a Copy+Paste of a form example that demonstrates this pattern, but it won't work out of the box because it depends on a lookup table that your project space won't have. It might be useful to see what the finished product looks like, though. It's a fairly small number of elements, just a matter of fitting them together.

Form Builder clip	version 1
id	type	labelItext:en-default	labelItext:es-default	labelItext:fra-default	appearance	calculateAttr	comment	dataSource	instances	itemsetData	rawRepeatAttributes	relevantAttr	repeat_count
/this_form_demonstrates_a_core_pattern_for_using_a_multi-select_to_display_a	Trigger	This form demonstrates a core pattern for using a Multi-Select to display a list of items, then providing a model iteration which shows one repeat group for each item selected.	This form demonstrates a core pattern for using a Multi-Select to display a list of items, then providing a model iteration which shows one repeat group for each item selected.	This form demonstrates a core pattern for using a Multi-Select to display a list of items, then providing a model iteration which shows one repeat group for each item selected.	minimal	null	null	null	null	null	null	null	null
/filtered_iteration_group	Group	null	null	null	null	null	Copy / Paste this unit into your form to copy	null	null	null	null	null	null
/filtered_iteration_group/choose_the_items_to_include_in_the_repeat	MSelectDynamic	Choose the items to include in the repeat	Choose the items to include in the repeat	Choose the items to include in the repeat	null	null	null	null	"{""item-list:iterables"":{""src"":""jr://fixture/item-list:iterables""}}"	"[{""instance"":{""src"":""jr://fixture/item-list:iterables"",""id"":""item-list:iterables""},""nodeset"":""instance('item-list:iterables')/iterables_list/iterables"",""valueRef"":""unique_id"",""labelRef"":""name""}]"	null	null	null
/filtered_iteration_group/iteration/item	Repeat	null	null	null	null	null	"This iterates over ALL items in the table, but downstream we will filter only the ones to display.

NOTE: in Live Preview you will still see whitespace allocated per ""hidden"" filter group below, but this won't appear in production web apps or on the mobile"	"{""idsQuery"":""instance('item-list:iterables')/iterables_list/iterables/unique_id""}"	"{""item-list:iterables"":{""src"":""jr://fixture/item-list:iterables""}}"	null	"{""jr:noAddRemove"":""true()""}"	null	/data/filtered_iteration_group/iteration/@count
/filtered_iteration_group/iteration/item/item_id	DataBindOnly	null	null	null	null	../@id	null	null	null	null	null	null	null
/filtered_iteration_group/iteration/item/name	DataBindOnly	null	null	null	null	instance('item-list:iterables')/iterables_list/iterables[unique_id = current()/../item_id]/name	null	null	"{""item-list:iterables"":{""src"":""jr://fixture/item-list:iterables""}}"	null	null	null	null
/filtered_iteration_group/iteration/item/filter	Group	null	null	null	null	null	This group filters out items which weren't chosen by the user	null	null	null	null	selected(#form/filtered_iteration_group/choose_the_items_to_include_in_the_repeat, #form/filtered_iteration_group/iteration/item/item_id)	null
/filtered_iteration_group/iteration/item/filter/etner	Text	"Arbitrary question about <output value=""#form/filtered_iteration_group/iteration/item/name"" /> "	"Arbitrary question about <output value=""#form/filtered_iteration_group/iteration/item/name"" /> "	"Arbitrary question about <output value=""#form/filtered_iteration_group/iteration/item/name"" /> "	null	null	null	null	null	null	null	null	null```