Skip to main content

How to conditionally make a field editable or read-only

Follow this guide to show a read-only or editable version of your field conditionally

Making the actual Read-only setting conditional is not currently supported. Neither is having multiple different expanding forms for the same portal table or form linked record field. Use the workaround described in this article or use separate forms for different scenarios instead.

This is useful in any situation where you need to show a different form based on a record status, for example within a portal or a form's linked record field you can show an editable form when the status is 'draft' and a read-only form when the status is 'closed'.

When editing a record, you can configure a field to be editable only when specific conditions are met and show a read-only version at all other times using the following setup:

  • Make the field conditional using the Conditional Field setting, so it will only appear in the form to be edited under certain conditions, like when a specific option is selected on a single-select field, for example.

  • Create a new formula field in your Airtable base with a formula that copies the content of the field in step one. Use curly brackets and the field's name like this:

  • Go to miniExtensions and add the new formula field to your form. By default, formula fields are read-only.

  • Make the new formula field conditional as well, but with the opposite conditions to the original field, so it will appear when the editable version is hidden. You can combine many conditions to find the correct mix for your specific requirement. Here's an example:

If your editable field appears only when a "Status" field shows 'Created', you can make the read-only formula field appear only when the status is NOT 'Created'.

With this setup, when the "Status" conditions are met, your users will see the editable field; when they aren't, they will only see the read-only formula version of the field that shows the same data contained in the original field.

While Airtable does not allow two fields to have the same name, you can set a custom field title in the Standard Options section, so your formula field shows under the same name as the regular field, which creates a seamless experience for the end user.

How to set up an entire read-only form based on conditions

If you need to essentially show a read-only form under certain conditions, and an editable form under others, the approach explained above works, but can require a lot of duplicate fields if your form needs many. There is an easier way to achieve this same result, however.

Instead of adding a duplicate formula field for each form field, you can instead create one formula field that contains data from all fields that you want to show in a read-only manner, with the field titles being part of the formula itself. Then, instead of showing multiple formula fields conditionally when the status is, say "pending", you just show that one field. Formula fields on miniExtensions support HTML, so you can format the field titles differently from the actual content. ChatGPT or similar can help generate the formula if you give it your field names and the desired titles. You can also choose to hide the formula field's title for a cleaner look.

The formula may look something like this:

"<h2>Customer</h2><p>" & {Customer} & "<p><h2>Message</h2><p>" & SUBSTITUTE({Message},"\n","<br>")

The output for this formula would look like this:

The SUBSTITUTE() function in the example formula above is used to preserve line breaks in the long text field.

Related

Did this answer your question?