A conceptset
type holds a set of items of type concept
. This conceptset
has no predefined range and accepts any concept
, which distinguishes it from a concept data field that does have a range.
In this example, we register input
for our @ConceptSetProperty
, and we store the output ID in a variable called @id
. This is important because all checkboxes must share the same name according to HTML specifications. Next, we loop
through the range of @ConceptSetProperty
to generate the checkboxes. We set the name to @id
, the value to ConceptId(concept)
, and check if @ConceptSetProperty contains concept
. If it does, we add the "checked" attribute to the checkbox. After rendering the checkbox input, we display the name of the concept using <?= concept ?>
.
In the background, during a postback, we send back a list of IDs that will update the data model bound to @ConceptSetProperty
.
The following example demonstrates a less user-friendly UX for updating a concept set. However, it illustrates the concept of updating a concept data model with a postback using a single input field—in this case, a text field.
This widget renders all the concepts along with their concept IDs from the range of @ConceptSetProperty
. When @ConceptSetProperty contains concept
, that concept will be included in the value of the text field. The result will be a comma-separated list of IDs, e.g., 1,23,400
. To update the concept set, you simply modify the text value, which holds the IDs that are part of this concept set. Note that the format is very strict; for instance, the value 3,70,
with an additional trailing comma at the end is not accepted by the WEM runtime and will result in an empty concept set.