How to pre-fill objects in form submissions
- In this lesson:
- 1Configure pre-filling of objects
- 2In the form designer
- 3In the form submission
Configure pre-filling of objects
Objects can be pre-filled in the form submission based on an existing relation in TE Core, i.e there needs to be a relation configured between two object types. In addition, the relation needs to be mapped in the settings page of TE Preferences.
Go to the settings -> TimeEdit integrations -> Relations. Select to relate the two types to one another.
In the form designer
The pre-filling of objects can either be done between two datasource elements within the same section, or between the primary object and a datasource element. We do not yet support pre-filling of objects between datasources in two different sections, i.e between a regular section and a table section.
Pre-fill between two datasource elements
- Add a section in the designer
- Add one datasource element
- Select the first object type, e.g course event (important so select the actual object and not the field value of an object)
- Add a second datasource element
- Select the second object type, e.g module (again, important to select the actual object)
- If a relation is mapped in the settings page, an option for "Object relations" will automatically appear in the datasource element
- Open the dropdown and select to the "course event element"
- Open the dropdown for "Pre-fill related objects"
- Select one of the three alternatives for pre-filling
- Don't Prefill - No objects will be prefilled, the related objects will only be shown in the object selection list to the form submitter
- Prefill, allow editing - Related objects will be prefilled and the submitter can add or remove objects
- Prefill, do not allow editing - Related objects will be prefilled and the submitter can not edit the objects
Pre-fill between primary object and datasource
- Select the primary object type in the settings page of the form designer
- Go to the designer tab
- Add a section and a datasource element
- Select the object type (important so select the actual object and not the field value of an object)
- If the selected type and the primary object have a relation, the option to select objects relations appear
- Open the dropdown and select "primary object"
- Open the dropdown for "Prefill related objects"
- Select one of the options which allows pre-filling
Allow multiple values
Please note that if there are multiple objects related to one another, e.g multiple programs related to one course event, remember to enable the option for "Allow multiple values" in the datasource where the objects should be pre-filled. If this option is not enabled, only the first related object in the list will be selected.
It is possible to allow multiple values in both of the datasource elements, e.g the submitter can select multiple course events in one element and then get all of the related programs pre-filled in the other one.
In the form submission
If the option to pre-fill is enabled in the designer, the below example means that based on what course the submitter selects, the related program will be automatically selected. In this example the submitter is allowed to edit.