Subforms

This guide uses a leave application example to explain how to create and link subforms in Joget, illustrating the relationship between parent and child forms.

Relationship Overview

One leave application can have multiple leave details.

Form ID Table Name
leaveApplication leave_application
leaveDetails leave_details

Instructions

  1. Create the Child Form leaveDetails.
  2. Add a field named leave_application_id to store the ID of the parent form.


  3. Create the Parent Form leaveApplication.
  4. Optionally, add a field named leave_details_id if there's a one-to-one relationship between the parent and child forms.
  5. Embed the Child Form in the Parent Form, drag the SubForm element into the desired section of the leaveApplication form, select the leaveDetails form to embed.

Linking the Child Form to the Parent Form

To establish a link between the child form and the parent form, configure the properties of the subform input.

Edit Subform Input Properties:

  • Parent Field to keep Subform ID: Enter the ID of the field in the parent form used to store the ID of the child form. For example, leave_details_id.
  • Subform Field to keep Parent ID: Enter the ID of the field in the child form used to store the ID of the parent form. For example, leave_application_id.

When using your parent form in a process activity, the system will automatically populate the IDs of the parent and child forms upon form submission.

One-to-One Relationship

Select a form to be used in the subform properties in a one-to-one relationship. The child record will use the parent form ID as the primary key. In this example, set the Parent Field to keep Subform ID so that the parent form references the child record.

Example Data:

  • Table: leave_application

    Id leave_details_id ...
    1550 1550 ...
  • Table: leave_details

    Id leave_application_id ...
    1550 1550 ...

Following these steps, you can effectively create and link subforms in Joget, maintaining a structured relationship between parent and child forms.

Created by Julieth Last modified by Aadrian on Dec 13, 2024