Merge Question Values
You can merge values from multiple questions into a single array or object. This functionality enables you to split complex forms into connected parts. For example, you can create a form where users enter a list of employees in one question and fill out details about them in a dedicated section of questions that generates dynamically once a new employer has been added to the list. If you link the questions with each other, their values will be merged into a single array.
Associate Compatible Questions
To link two questions, set their valueName
property to the same value. This value will be used as a name for the property that will contain the merged array. In this demo, the employment history form contains two questions of the Dynamic Matrix and Dynamic Panel types. Respondents enter a list of employer names into the matrix and details about each employer into multiple panels. Together, Dynamic Matrix and Dynamic Panel produce an employees
array of objects. The matrix supplies the employee-name
field values; the panel supplies the remaining field values. Once bound via valueName
, two questions can reference each other's values. For example, values from the matrix can be displayed in panel headers, as shown in this demo.
Associate Incompatible Questions
Dynamic Matrix and Dynamic Panel are compatible because they both produce arrays of objects when they are used as standalone questions. In some instances, you need to associate two or more questions that produce results in different formats and as such are incompatible. For example, the Checkboxes question type produces an array of primitive values, and a primitive value cannot be merged with an object. To force a Checkboxes question to produce an array of objects, specify the valuePropertyName
property with a field name that should store question values.
In this demo, on the second survey page respondents are asked about their language skills. Respondents should select languages they speak from a Checkboxes question. For each selected language, a Dynamic Panel question generates a detail panel. The two questions are associated via valueName
, and the Checkboxes question produces an array of objects. The language
object field stores the selected language. This field is used to reference languages in panel headers.