Linking Forms - From one to many linked forms - Hierarchy
The ability to define any number of text and or media fields, in combination with logic such as jump questions and the validation methods detailed in the previous instructions, provides a flexible framework for describing many kinds of complex projects within a single formdata gathering project.
However, a single form may sometimes not be adequate for the kind of project you wish to undertake, and we provide the ability to link multiple forms together within a single project in two ways; in a hierarchy or branching.
Within our demonstration schools project, we defined a set of questions which allow us to gather certain kinds of information about a particular school. However, (as demonstration), maybe, as we carry out our project, we realise that it would also be useful to capture information about all the teachers within a particular school. In this instance, we would like to ask a series of questions to each teacher, within each school.
We could simply define a second project with a 'teacher' form and carry out a second survey, however, data for each school would not be linked to each teacher. What would be more convenient would be for us to add multiple instances of a teacher form, to a particular school, all within the same project. Furthermore, what if we decided that as we are undertaking the project, we would also like to collect information about pupils linked to each teacher?
Within this expanded schools project, there are three single forms - one for a school, one for a teacher and one for a pupil. Data gathering would occur in what can be envisioned as a hierarchical fashion (or one-to-many). For each school, there will be many teachers, and for each teacher, there will be many pupils.
These relationships can be visualised as in the following figure:
So, within our schools project, three forms will be utilised and are linked together as follows:-
This hierarchy is top to bottom and allows data gathering in a 'one to many' fashion. For example, each Form A entry (a school) can have many Form B entries (each teacher in the school), which in turn can have many Form C entries (each pupil of each teacher in the school) etc..
How to link forms together - Using KEY Fields
To preserve the relationship within each level of the hierarchy when defining forms, the KEY FIELD is utilised. When we define our second form (teacher), we automatically include the Key field from the form above in the hierarchy (The School). This means that when data are stored, all instances of the teacher form, automatically include the key field from the school form, allowing each teacher to be uniquely linked to a school.
Similarly, when defining a pupil form, we automatically include the key field defined in the teacher form, so that each instance of a pupil form is uniquely linked to a teacher, which in turn is linked to a single school.
To demonstrate simply, we will create a new project called Schools2 and define three simple, linked forms - School, Teacher and Pupil.
For simplicity, we will only define two fields for each form, but bear in mind that all of the input types (text and media) along with form logic and validation can be defined for each form as previously demonstrated.
The Questions within each form will be as follows:
Form 1 - School
Q1 - What is the name of the School - This will be the KEY Field
Q2 - What type of school is it? - A simple drop-down with three choices - 'boys', 'girls' or 'mixed'
Form 2 - Teacher
Q1 - What is the name of the teacher? - This will be the KEY Field
Q2 - How many years has the teacher been at the school? - A simple numeric field.
Form 3 - Pupil
Q1 - What is the name of the pupil? - This will be the KEY field
Q2 - What age is the pupil? - a simple numeric field.
Defining Form 1
Firstly, we will define the 'School' Form using the Form Builder as in the following screenshot:
Now we define the Key Field with the Label 'What is the name of the School?' and the ID 'SchoolName'.
Now we add the second question in the School form - a dropdown with three options for the question ' What type of school is it? with the ID 'SchoolType':
Defining Form 2 - Teacher
Firstly, we click on the button at the top left 'Add a Form' and enter the form name - Teacher
We now define the Key Field for the Teacher Form with the Label 'What is the name of the Teacher?' and the ID 'TeacherName' :
The linking Key:
In the screenshot below, you willl see that the Key field from the School Form (ID:SchoolName) has automatically been inserted into the Teacher Form, just above the Key Field for the Teacher Form(ID:TeacherName) and indicated with an arrow). This ensures that any teacher form filled in, also includes the link to a School.
We have also added a further numeric question (How many years has the teacher been at the school?'
At this point, you could set the Linking 'SchoolID' field as Hidden within the Teacher form, meaning that it would not be seen by the user (as it's value is imported from the School form). However, for demonstration purposes we will leave it as is.
Defining Form 3 - Pupil
After saving the Project, we again click 'Add a new Form' and give this new form the name 'Pupil':
We then, as previously, define the Key Field for the Pupil Form with the Label 'What is the name of the Pupil?' and the ID 'pupilName:
The linking Key:
In the screenshot below, you willl see that the Key field from the Teacher Form (ID:TeacherName) has automatically been inserted into the Pupil Form, just above the Key Field for the Pupil Form(ID:PupilName) and indicated with an arrow). This ensures that any Pupil form filled in, also includes the link to a Teacher (which in turn links to a school).
We have also added a further numeric question 'What is the age of the pupil?'.
On the mobile device
Below we will walkthrough basic data entry for this three form project. We will detail the workflow for a single instance of each form, however of course, multiple instances of each form can be added.
Firstly, after loading the project, and tapping 'Start/Resume Data Collection'' a user is presented with the three Forms listed as in the following screeshots
Tapping 'School' takes the user to the School form menu and tapping 'Add School' allows the user to progress through the School Form as in the following screenshots:
After the form is complete and the user taps 'Store' they are presented with four options. At this point, they can choose to Add Another School, which will allow them to add a new entry as previous. Tapping 'Add Teacher to School' will assign a teacher form to the school just created. Firstly, the user will be presented with the Teacher Form Menu as in the following screenshots:
After the form is complete and the user taps 'Store' they are presented with four options. At this point, they can choose to Add Another Teacher, which will allow them to add a new entry as previous. Tapping 'Add Pupil to School' will assign a Pupil form to the Teacher just created. Firstly, the user will be presented with the Pupil Form Menu as in the following screenshots: