Configure a checkbox that saves a boolean (true/false) value, and validate that the user selects the checkbox before submitting a form.
This scenario demonstrates:
How to configure a checkbox field so that a single user interaction records a true or false value
Test it out
Click "Submit" without selecting the checkbox. Notice that the custom message shows up. Appian recommends using a custom required message when you have a single required checkbox.
Select the checkbox and click "Submit".
Notable Implmentation Details
Unchecking the checkbox saves a value of false. However, the initial value of local!userAgreed is null, which also results in the box being unchecked. Therefore, you may need to account for values of both false and null in your interface. Alternatively, you can set the initial value of local!userAgreed to false to avoid null values entirely.
In this recipe, we had to modify the value of the component in addition to the saveInto. We had to do that in order to save a value of false, which is not a valid option in our checkbox field that only has one option. This design pattern works because both the value and saveInto parameters are set using the same variable, so the component responds to the user's interactions.