For developers: Make a field in a form response hidden or read-only on the frontend
Form render modes
The Form widget supports the following modes:
- Create mode
Used when the form is empty and the user can submit new entries. This is the default mode when the form is loaded on the page. - Update mode
Used when the form is already filled out and the user can update it.
To load the form in update mode, a specifically generated query string must be appended to the page. For more information, see For developers: Generate a query string for editing a form response on the frontend.
Field types that support hidden and read-only rendering
When creating or editing a response in the frontend, it is possible to restrict specific fields as hidden from the user or locked for editing as read-only.
The following field types support hidden and read-only modes:
- Textbox
- Multiple choice
- Checkboxes
- Paragraph text box
- Dropdown list
- File upload
The fields above have two specific properties - ReadOnlyModes and HiddenModes. You can edit those fields in the Advanced mode of the respective form widget. For more information, see Configure form widgets.
ReadOnlyModes and HiddenModes field properties
When the form is rendered, for each rendered field, the advanced properties HiddenModes and ReadOnlyModes are evaluated.
The HiddenModes and ReadOnlyModes properties can have one of the following values:
- create
The field is hidden or read-only when the form is rendered in create mode. - update
The field is hidden or read-only when the form is rendered in update mode. - create;update
The field is hidden or read-only when the form is rendered in both create and update modes.
Configure the value of ReadOnlyModes or HiddenModes properties
Each form field that supports hidden and read-only mode has fields ReadOnlyModes or HiddenModes. You configure these properties in the respective form widget. For example, to hide a Textbox, you must open the Textbox form widget.
Perform the following:
- In Sitefinity CMS backend, click Content » Forms
- Open the form whose fields you want to hide or make read-only.
- Click the Edit button of the form widget whose fields you want to hide or make read-only.
- In the widget designer, click Advanced button.
- To hide the form field, set the value of HiddenModes to create, update, a custom value, or a combination of the three, delimited by a semicolon.
For example, if you use the implementation in Customize the hidden and read-only modes, you can set the value to anonymous to hide the field whenever the current user is not logged in. - To make the form field read-only, set the value of ReadOnlyModes to create, update, a custom value, or a combination of the three, delimited by a semicolon.
For example, if you use the implementation in Customize the hidden and read-only modes, you can set the value to admin-mode to lock the field whenever the current user is an administrator.
- Save your changes and publish the form.