...
This tutorial is relevant for
Low-Code Developers Automation Experts who want to learn how to create and display web forms as a fundamental part of an application to accomplish several critical objectives like: Data collection, data review and data validation.
...
Login to portal with a valid developer account.
Navigate to LOW CODE → Properties.
Click the plus + icon at the top.
Select App and create a new app with name:
io.pipeforce.tutorial-03-forms
.Select this app and click again the plus + icon.
Now select Form Schema and create it inside this app with name: person.
The new schema was created and pre-filled with an example person schema.
Later, you can edit this form schema and remove, change or add data fields to your form.
For this tutorial, do not change anything and leave it as it is.
Info |
---|
At this step you have created a Form Schema which defines the fields and their data types of the form. For more information go to the public docs: Form Schema. |
...
Go to LOW CODE -> Properties.
Select your app
io.pipeforce.tutorial-03-forms
in the tree.Click the plus + icon.
Select Form Config.
Create a new Form Config with name: person
In the property tree, select your app and click on the plus icon + to create a new property inside.
Give a name to the Form Config then click Create.
A new Form Config was created for you with a pre-configured title and configuration.
Leave this Form Config as it is for now.
10. Since we did not specify any layout information here, the default layout will be used: All fields defined in the Form Schema will be displayed in vertical format.
...
Info |
---|
For more details go to the public docs: Form Config. At this step you have created a Form Config which defines the configuration and optionally layout customization, validation rules and script references. |
Step 3: Execute the Form
After the Form Schema and the Form Config have been created, you can open your form.
To do so follow these steps:
Navigate to APPS -> Installed Apps.
Click on the app io.pipeforce.tutorial-03-forms.
Click on person.
Now you should see the form with the example fields like this:
Submit the form
Add valid values in any of the fields.
Click on SUBMIT.
Noteworthy
After you clicked on SUBMIT, the form data will be validated and then send to the server as JSON. This JSON will then be stored to your app's data folder: io.pipeforce.tutorial-03-forms/data/...
Any new submit will create a new entry in the data folder with a random uuid.
The reason why this works this way is because in the Form Config, the output path was configured to this location, like this:
Code Block |
---|
"output": "$uri:property:global/app/io.pipeforce.tutorial-03-forms/data/person/" |
Note: Since this path ends with a /
, a new entry is created with a random uuid every time you write to this URI location.
Info |
---|
In the next step of this tutorial, you will learn how to handle such a form submit in the backend in order to execute some additional action after the user has submitted a form. |
Step 4: Handle the Form Submit
In this step you will learn how to handle a Form Submit at server side and add logic to be executed after submit.
Info |
---|
Noteworthy
|
Follow these steps in order to trigger a pipeline after the form was submitted:
This pipeline should then send an email.
Go to AUTOMATION -> Properties.
Select your app io.pipeforce.tutorial-03-forms.
Click the plus + icon.
Click Pipeline and create a new pipeline
Give the pipeline a name and then click Create.
Copy and paste this YAML script to the pipeline editor and overwrite any existing content:
Code Block | ||
---|---|---|
| ||
pipeline:
- event.listen:
eventKey: property.created
filter: ${body.target.path.contains('global/app/io.pipeforce.tutorial-03-forms/data/')}
- mail.send:
to: name@email.tld
subject: "Form was submitted"
message: |
The form was submitted:
${body.target} |
As you can see, this pipeline listens to the property.created event. Since the form submit writes to the location global/app/io.pipeforce.tutorial-03-forms/data/
(as configured by the output parameter) you can listen to this write event and execute your business logics. Which is sending a simple email in this example.
Change the email address
name@email.tld
to your own address.Save the pipeline. After save, the pipeline will be automatically registered as a listener to the property.createdevent.
Execute the form again.
10. You should now receive a new email on any form submit.
Info |
---|
In this step you have learned how to execute logic at server side after a form has been submitted. |
Step 5: Customize Form Layout
In this step you will learn how to change the default form layout
Info |
---|
Noteworthy
|
Follow these instructions in order to change the default layout of your form:
Go to AUTOMATION -> Properties.
Open the Form Config
form/person
inside your app io.pipeforce.tutorial-03-forms.Replace the content of the Form Config by the JSON listed below, and then click SAVE
Code Block | ||
---|---|---|
| ||
{
"id": "person",
"title": "Add person",
"public": false,
"description": "",
"schema": "$uri:property:global/app/io.pipeforce.tutorial-03-forms/schema/person",
"output": "$uri:property:global/app/io.pipeforce.tutorial-03-forms/data/person/",
"layout":{
"orientation":"vertical",
"items":[
{
"orientation":"horizontal",
"title": "Name",
"border": true,
"items":[
{
"field":"firstName"
},
{
"field":"lastName"
}]
},
{
"field":"age"
},
{
"field":"gender"
},
{
"field":"birthDate"
}
]
}
} |
As you can see in the Form Config, the layout part was added which defines a different orientation of the fields.
Navigate to APPS -> Installed Apps and click your app io.pipeforce.tutorial-03-forms.
Now you should see that the “person” tile has changed to “Add person”. Click it.
Here you can see the changed layout: first Name and last Name fields are now in the same line (horizontal) and all other fields are in separate line (vertical):
...
Info |
---|
For more information about layout options, go to Form Config & Layout. |