Skip to content

Instantly share code, notes, and snippets.



Last active Dec 14, 2015
What would you like to do?

Adding a prompt that gives the option to launch a subform:

type name label
launch_subform [subform_name] ? Press the button below to fill out the initial visit form.

Adding a prompt that shows all the subforms created so far, and gives the options to add/remove them.

type name label
repeat_subform [subform_name] ? Household members:

We should pass the entire subform table into the template so the prompt can be easily customized to include any information deemed necessairy. e.g.

{{#each subform_table_row}}

Implementing subform launching:

When a subform is launched only the parent form name, instance id, and launching page/prompt name need to be passed. These should be stored in the child form table so they are not lost if nested subforms are launched. Variables from the parent form can be accessed via database query.

To add subforms we need to create the necessary prompt types and modify the ODK Survey url router to deal with the additional parameters as follows:

If parent_form, parent_instance, and parent_prompt are provided they are stored in the metadata(?) table, and a new instance is immediately created rather than going to the instance list. If the parent_form field is present, the parent form is relaunched when the child form is completed. The parent_form metadata can then be used to relaunch the parent form when the child form is completed. Launching is as simple as setting the url hash with the appropriate parameters.


Should subforms create fields in the parent table with references to them? Some of the consequences of this:

  • The name column will be required on subform prompts.
  • I suspect having the extra columns will make it easier to link to child forms in Tables.

Should the parent form be responsible for specifying the instanceID of the child? This would make things simpler as we wouldn't have to pass the child instance id back to the parent. We already parse instance id parameters so it's no extra work to pass the instance id into the child form.

Other possibly unnecessairy features:

  • Transparently launching subforms within a survey, as though they are part of the survey.
type name label
embed_subform [subform_name]
  • The ability to define subforms on separate pages of the parent form workbook by creating sheets with the following naming convention: subform.[name] First we would look for subforms within the workbook. If they are not found then we would go to the sdcard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment