In this chapter we will add validation to the data users type into forms. To do this, we need to add custom actions to insert and update actions. Adding custom actions is an important steps, and allows you to do many things with actions beyond validating data. When adding custom actions to update and insert actions, there are a couple of crucial things to remember:
To recap the steps in the video:
- Add a new attribute to the stream
Contacts
:BusinessName
- Drag this into both the top grid view and the bottom edit form of the dashboard
Contacts
- Now add an action to validate the data typed in for both new contacts, and contact edits:
- Open the configuration form for the stream
Contacts
- Go to the section Actions, and add a new action
- Give the action the following settings:
- Name:
Validate Contact
- Display Name:
Validate Contact
- Go to the section Update StreamItems
- Set Stream Item Action to Update
- Press Apply
- Tick Copy Values by Name
- Name:
- Open the configuration form for the stream
Copy values by name updates the underlying stream with values types into a form if the names of the fields match. All standard actions will do this. When you add a custom action to update or insert, it is important that you tick this, otherwise the form will not continue to work as it currently does, and you will not be able to easily as new fields as you have done so far.
In future exercises we will look at cases where you might not want this flag ticked, and cases where the flag is ticked, but for particular fields you can override the copy to set the value to something else.