Power pages form component can be used to collect data from users and save it in the database of the Power Pages website. You can add a form to a Power Pages website using these 4 steps
- Setup a database
- Setup database write permissions
- Setup a form connected to the database
- Add the form component in the “Page Builder”
Setting up Database for Power Pages Form
In this section we will look into creating a database for the form. Let’s take an example where we need to collect preferences for the offsite that your company is organizing.
We will create a simple form that takes the following 3 fields
To create a new database, select the “Data” option from the main menu in the left panel
As you can see, there are tables listed. Associated with every table would be 3 more components
- Table data
Let’s start by creating a new table by clicking on + as shown in blue in the above image.
Add the table name, plural name and click on create. This would create the table. Once the table is created click on “New Column” in “Table data” to add new columns. We can see that name is already present as a column. We will add 2 more columns
Once you have added both columns, we will proceed to create a new form.
Setting up the form
Click on Forms, followed by “New Form”
Enter the form name and click on create. Once the form is created, click on “Add field”
Now, add the date & place preference fields that we created to the form and save the form. We are done with the database and form setups.
Now that we have created the table and form, we will have to set the form permissions so that it would be accessible from the website.
In order to do this, follow these steps as shown in the diagram below.
- Click on “Set Up”
- Click on “Table permissions”
- Click on “New permission”
- Enter Preference Name
- Select the table that we created earlier “Offsite Preference”
- Give “Create” permission
- Add role -> Anonymous Users
Power Pages form on website
The last step of the process is to add the form component to the website. Inorder to do this, click on “Pages” & select the page you want to add the form component to. To learn about how to build pages, refer to this article.
Add a new component and select the type as “Form”. It will popup further questions as shown below
In this select “Offsite Preference” as the table where the form data will be saved. Select the form “Take Place Preference” that we had added earlier and hit OK.
If you preview the website, you will see the form there.
Congratulations, you have successfully created your form. Once you have created the form, try it out using the website preview option. Once you add the data in the form, it will be visible in the database data as shown below
It is so easy to create a form and collect data using “Power Pages”. Do let us know as to how are you’ll using Power Pages to create forms in the comments below.