Legacy Knowledge Base
Published Jun. 30, 2025

How to create a read-only field in a form

Written By

Alvaro Cabello Díaz

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • When you are creating a form, sometimes you want to create a field that is read-only because, for example, it is automatically populated by taking information from an API or a database, and you don't want the user to modify it.

  • From Liferay, it was thought to introduce this option, you can see it in the following Feature Request LPS-193313, but it was discarded because it would produce an inconsistency of behavior between the UI and the API that they do not see safe.

Environment

  • Liferay DXP 7.1
  • Liferay DXP 7.2
  • Liferay DXP 7.3
  • Liferay DXP 7.4
  • Quarterly Release

Resolution

This workaround allows you to modify this property to create read-only fields:

  1. Create the form as you wish, including the field or fields that you want to be read-only and publish the form.
  2. Go to the 3 dots on the top bar and click on the import/export option. Configure the export and the content as you want and click Export.
  3. Download the .lar file and open it. Go to the file ddm-form.json which is in a similar route to this one: /group/20117/com.liferay.dynamic.data.mapping.model.DDMStructure/34408/
  4. Open that file and change the “readOnly” value, set it to “true”, from the field that you want and save the file.
  5. Now import that .lar, and you will have your form with a read only field.
Did this article resolve your issue ?

Legacy Knowledge Base