What are Forms?
A form view is used to add or edit a record in your database.
Forms are used to insert or update records for one of the objects in your database. Any of the object fields can be used as form inputs to be filled out by the user. A form can insert a new record or update an existing record.
What do Forms look like in a live app?
In the live app, fields from your object are used as form inputs and displayed as shown below:
Where do I access Forms?
You can access your form from the Pages section of the Builder by selecting the page containing your form view. The form view has a checkbox icon and is labeled with the form’s name.
Add a Form
You can add a form by selecting the Form view from the toolbar at the top of any page:
Add a Form to Create a New Record
Select the object you want to insert new records into, and then click the "Add form" button:
Add a Menu That Links to a Form
You can also add a menu button to your page that will link to your form. This is useful when you want to have a form pop up in a modal window, or you'd like to display further details along with the form.
You can do this by selecting the option to "Link to this form from a menu" above the Add Form button whenever creating a new form:
Once added, a menu button will be added to your page which users can click on to be taken to your form. This is ideal for pages that contain multiple views:
In the example above, clicking the Add Contact button will take the user to a form that creates a new Contact record when submitted:
Display Form in a Modal Popup
If you'd like your form to display in a popup or modal window, to create a smoother workflow, you can do this by first linking to a form from a menu, and then editing the settings for the page to select the 'Display page in in a modal popup' option.
Add a Form to Update Existing Records
You can add a form to update an existing record on any details or edit page. Simply select the Form option from the view's toolbar and you'll have the option to add a form to update the record:
Add a Form to Insert a Connected Record
If your app is using connections, you can add forms to insert connected records to any details page. For example, in the example below, you can add a Form view to the Company details page that will add a new Contact record connected to that Company.
You can also go one step further and add a form that will create a record further connected to your parent object. In the example below, although Company is the page's source object, the form will create a new Note record connected to the Contact connected to the page's Company record.
Edit a Form
To edit the form, click the form view or select the gear icon on the form view in the Pages section of the Builder.
This will open the Form Settings page, where you can use the menu on the left to edit different aspects of the form.
Delete a Form
To delete a table from your page, just click on the trashcan icon on the table view.
Warning: Please note that deleting a table view will also delete any child pages connected to it.
Copy or Move a Form
To copy your form, click and drag the form view from its original page and drop it on a new page in the page hierarchy tree. This will trigger a Copy/Move pop-up menu:
You can also copy or move a form by editing the form view on your page, clicking the gear icon in the top-right corner of the form settings page and then selecting copy or move from the dropdown menu:
To move your form view and rearrange your page, click and hold the form view and move it above or below other views present on the page.
Note: Views can only be copied or moved to pages with the same parent object or a connected object.
Once a form has been added, either click directly on the form view or click the gear icon to manage its settings.
The Data Source section displays more information about the record being inserted. It will tell you what the parent object of your form is:
When forms are added to insert a connected record, the connection is automatically set by Knack behind the scenes and you don't need to include that connection field on the form. For example, this form will add a Contact record that is connected to a specific Company:
For forms that do not insert connected records, you can add connection fields as you would any other fields. Connection fields work like "look-ups", where the user can look up a specific record or records to connect to.
The Inputs section determines which fields are included in the form:
A title and description are listed above the input fields, and you can click on each to add or edit. These are optional and will display at the top of the form if added:
When you add a new form all the fields are added as form inputs by default, however, if you add a new field on the Object in your 'Data' section of the builder, you will need to add that to any form you'd like to include that on.
Add Field Inputs
The left menu lists all the fields available to add as inputs. Click on a field to add it to your form.
Each field can only be added once, and any fields that have already been included in your form will be grayed out. When added, each field will preview with an input based on the field type.
Add Connection Field Inputs
In a form, a one to many connection field looks like a drop-down with the added feature to dynamically search the available choices. For example, if you had one Company connected to many Contacts, the field would display as shown below:
A connection field connecting to many to many connection lets you select more than one record at a time. For example, if one Contact connected to many Companies, the field would display as follows on a form:
Add Special Inputs
Clicking the Special tab in the Inputs menu allows you to add a Title/Instructions field to your form:
This field lets you insert titles and text throughout your form. This field can be edited by clicking the edit icon on the field:
This is how it will look in your form:
Fields are organized into groups that can be laid out into one, two or three columns. Click the "Add Group" button to add multiple groups:
With multiple groups, any fields you add as new inputs will be added to the active group. The active group will have a darker background and you can click on any group to make it active:
You can also change the layout of your groups to display form inputs in one, two or three columns. Hovering over a group will show the Layout option:
If you have more than one group you can click on the move icon above a group and drag to change the order:
Finally, you can change the order for any input by dragging and dropping it into a new location. Form fields from one group can be moved to another group:
To edit an input, hover over the field and click the pencil icon:
A window is displayed to edit that input:
- Field: The name of the field.
- Read Only: Selecting this option will display the field’s value without an option for editing the value in the form. This is only available on edit forms.
- Label: The label that displays with the input. This defaults to the field's name.
- Instructions: Add additional instructions for using the input. This will display in smaller text below the input, except in the case of paragraph fields, where it will display above the form input.
Both multiple choice and connection fields have options to allow a user to create new choices directly from the form. As an example, if you have a multiple choice field to select the Industry, and yours doesn't exist, you could add that as a new option.
This presents the user with a "plus" icon they can click to add additional options right from the form:
This creates a child form that can be managed in Pages like any other form:
Connections have an additional option. When you have multiple connection fields on a form and that are connected to one another, you will see the Show option for limiting which connected records are available to select from:
For example, if you have Departments connected to a Company record, you can limit the Departments that are shown here, by selecting to Show only the Departments connected with the form's Company.
Then, when a specific Company is selected on the form, only that Company’s Departments will show up for the Department field:
Connection fields can also have filters that will further limit which connected records are available to select from:
This will allow you to determine exactly which records will display in your connection field based on the filters you add. For example, if you only want to display Departments that have an 'Active' status, this could be done by applying filters.
Hover over an input and click the "trash can" icon to delete that input:
You can add powerful workflows to your forms with different Form Rules. There are three different types of Form Rules: submit rules, display rules, and record rules.
Submit Rules determine what happens after a form is submitted:
When: the criteria that will trigger the submit rule. The first rule present is the default action that will trigger when no other rule is met. You can add multiple criteria to each rule based on field values, in which case every criterion must be true.
Action: the result of the submit rule. The chosen action will occur once the criteria have been triggered. There are five actions that can occur once a submit rule has been triggered:
- Show a confirmation message: after the submission, the form will fade out and the confirmation text will appear. There are 2 additional options here: Show a link to reload a form and Automatically reload the form.
- Redirect to the parent page: after the submission, the user will be redirected to a parent page. This is perfect if you're adding a child record and want to quickly go back to a parent list showing all those records. This is also helpful when you are adding a new record from a popup modal form, and would like to refresh a table listing of to include your newly created record.
- Redirect to an existing page: after the submission, the user will be redirected to the selected page.
- Redirect to another website's URL: after the submission, the user will be redirected to the entered URL.
- Redirect to a new child page: create a new child page to direct the user to. You can add any views you wish to this page and it will automatically work with the form's record. This means you can insert a new record and immediately show other views for that record.
Display Rules control how the form is displayed. You can show and hide form inputs and change input labels based on other form and record values. These rules are checked and triggered when a user changes the value of a form or an edit form is initially populated.
A Display Rule is added by defining the conditions (if) that trigger the actions (then):
If: the conditions that will trigger the actions when each condition is true. More than one condition can be added to trigger the action, in which case every condition must be true.
Then: the action to trigger when the condition is met:
- Show/Hide: Show the input when the condition is true, hide it when it is false.
- Show: Show the input when the condition is true.
- Hide/Show: Hide the input when the condition is true, show it when it is false.
- Hide: Hide the input when the condition is true.
- Rename Label: Change the label of the input when the condition is true.
Multiple conditions and actions can be added for each rule by using the green "plus" button.
Knack Tip: A great use case is adding an "Other" or "Comments" field input for multiple choice fields. When the user selects "Other", the display rule can show a text input field that will gather more information from the customer:
Note: The "other" field input will need to be a field in your parent object before it can be added to your form.
Record Rules add or update records in your database. For example, you can insert or update a connected record, or update record this form is working with.
A record rule is added by defining an action and the conditions (when) that trigger the action:
Action: the action to take when the rule is triggered:
- Update this [the form’s] record: useful for setting status or workflow fields on submissions. You can also assign logged-in users, so you can track who submitted a comment, rating, or ranking on a form.
- Update connected records: similar but updating any records connected to the form's record.
- Insert a connected record: add a new record connected to the form record. Your form's object must be connected to other objects for this option to be available. Great for adding history, version, and archived records based on the submission.
When: the criteria to trigger the rule. Add criteria based on one or more form values, or you can run the rule for every form submission. Multiple criteria can be added, in which case every criterion must be true.
Values: When the action is inserting or updating records you can also set one or more Values for those inserts and updates. Values can be set to a:
- Connected value: choose a field from a record connected to the form record.
- Custom value: enter a value manually.
- Form value: choose one of the form inputs.
Knack Tip: Form Rules are triggered in the following order: display > record > submit.
You can trigger emails to be sent after a form is submitted:
Action: Choose the kind of email you would like sent.
- Send a basic email notification: Send an email containing all form inputs to an email address of your choice.
- Send a custom email: Customize your email contents and recipients.
When: the criteria to trigger the Email to be sent. Add criteria based on one or more form values, or you can run the rule for every form submission. Multiple criteria can be added, in which case every criterion must be true.
Send: customize your Email recipients. When an email field is chosen, the email address added to the form record will be used. If the field is a connected object with multiple records, an email will be sent to each connected email address. Recipient options include:
- To: the main recipient.
- CC: recipients who should receive a carbon-copy of the email.
- BCC: recipients who should receive a blind carbon copy of the email.
- Reply-To: the email address where email replies will be sent to.
- From Email: the email address the recipient will see the "From" email address.
- Email Subject: the subject the recipient will see for the email. You can use form field values in the subject line.
- Message: the message can be created by combining your own text and any fields available in the form record. Click on a field from the menu on the left to add it to the message. In the example above, both the Name and Birthdate fields have been added. When the email is sent those fields will be replaced by the actual values from the record. There are 3 template variables you can add to your message body:
- Record ID - Include the internal ID for the record. This comes in handy when you want to add a link to edit/view the specific record.
- Page URL - Include the URL for the form where the email is originating from.
- Parent Page URL - Include the URL for this form's parent page, if a parent page exists.
Knack Tip: HTML can be added directly to a custom email for additional formatting options.
The Options section lets you control different form elements, like customizing the Submit Button or Reload Form Text. If the form's object has a numeric field, you can enable an E-Commerce Checkout for your form:
Use Forms in your App
Form views are generally used to either add or update records in your objects. However, there are a number of other uses for forms as well.
Equations and Calculators
Forms can be used as online calculators by adding equation fields to the form. If you add the inputs that the equation uses the form, then the equation will automatically update as the user updates those fields.
Here's an example of an online calculator for calculating employee compensation based on a sales commission:
This will generally only work for simple equations like the above example. Current limitations include:
- Only numeric equations will work, date-based equations currently will not.
- All values for the equation need to be present in the form for the equation to calculate live.
- If values from connected records are needed, then the equation won't update automatically.
Notes & Troubleshooting
- If you need to add a new field to your form that doesn't exist yet, you'll first need to add it to your database.
- If you change the field name in the database, every existing input label will be updated unless the label has been changed to something different.
There are several How-To Guides that use form views to display records: