Monday, May 24, 2021

How to make an Oracle APEX text item read-only but retain the appearance of a data entry text item


Problem

You have a text field that you want to make read-only. You don't want to use a display item and you don't want to set the field to "read-only" in the attributes, thus making the field look like a display item (unless you mess about with CSS).

Solution

  1. In the "Identification" section of the attributes for the selected text item, set the "Type" to "Text Field".

  2. In the "Advanced" section of the attributes for the selected text item, enter the following in the "Custom Attributes" field:

    readonly=true


With these attributes set as shown above, the text item is displayed as a normal text item, e.g.


but now is read-only. If you select the field, it is not possible to edit the contents. Unlike setting the field disabled, the content of the field is not greyed-out, so is still perfectly visible.