# How to lock a field in an HFE Registration form?

**URL:** <https://talk.openmrs.org/t/how-to-lock-a-field-in-an-hfe-registration-form/44930>\
**Category:** Development\
**Tags:** html-form-entry, form\
**Created:** [February 14, 2025, 4:08pm UTC](https://talk.openmrs.org/t/how-to-lock-a-field-in-an-hfe-registration-form/44930 "2025-02-14T16:08:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![grace](https://talk.openmrs.org/user_avatar/talk.openmrs.org/grace/32/16942_2.png) [@grace](https://talk.openmrs.org/u/grace)\
**Post date:** [February 14, 2025, 4:08pm UTC](https://talk.openmrs.org/t/how-to-lock-a-field-in-an-hfe-registration-form/44930/1 "2025-02-14T16:08:54Z")

</div>

Hey O2 Form Expert friends @ball @mogoodrich - our friends at [@ICRC](https://talk.openmrs.org/groups/icrc) are looking for a way to lock a field on a registration form so users can’t edit it: E.g. in this case, the Odoo ID field is populated automatically, and one doesn’t want the user to change it.

Example:

**![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXdr-7ii6gM_HarsrJguDTIYzF5uzBT-sA8bUqPgWoN7WVKJb5S7bdkkpAWoJFH31fI2ylyjqeyBPhbGCykPhpIbdiGN1D2XVBtJcL7kbrKPUCSSZxiqWneuQjbkUaUktrmB9MNOsA?key=ZHnvZBPpk5GruoyDsmDYZA)**

Do you know how they’d set this? 🙏

---

<div class="post-metadata">

**Author:** ![ball](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ball/32/277_2.png) [@ball](https://talk.openmrs.org/u/ball)\
**Post date:** [February 14, 2025, 5:48pm UTC](https://talk.openmrs.org/t/how-to-lock-a-field-in-an-hfe-registration-form/44930/2 "2025-02-14T17:48:26Z")

</div>

@grace They should use a lookup to show (but it does not allow edit):

[https://openmrs.atlassian.net/wiki/spaces/docs/pages/25476979/HTML+Form+Entry+Module+Reference#HTMLFormEntryModuleReference-\<lookup\>](https://openmrs.atlassian.net/wiki/spaces/docs/pages/25476979/HTML+Form+Entry+Module+Reference#HTMLFormEntryModuleReference-%3Clookup%3E)

This is an example:

```auto
<lookup expression="patient.getPatientIdentifier(5)"/> this will get the patient's first identifier with Identifier Type Id of 5

```

---

<div class="post-metadata">

**Author:** ![ibacher](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ibacher/32/19751_2.png) [@ibacher](https://talk.openmrs.org/u/ibacher)\
**Post date:** [February 14, 2025, 6:38pm UTC](https://talk.openmrs.org/t/how-to-lock-a-field-in-an-hfe-registration-form/44930/3 "2025-02-14T18:38:44Z")

</div>

The registration app in O2 is not a HFE form at all, but it’s own thing, with it’s own configuration. Might be worth checking the [docs](https://openmrs.atlassian.net/wiki/spaces/docs/pages/25470818/Registration+App+Configuration). In this case, HTML input elements have a `readonly` attribute that makes the field uneditable. It seems like [the underlying component](https://github.com/openmrs/openmrs-module-uicommons/blob/363c137c5d83d99eac3c13dec76557bb9d222bd8/omod/src/main/webapp/fragments/field/text.gsp#L28) has some way to set other attributes, so if you could get `config.otherAttributes` there to include `readonly: true` that would probably do it.

---

<div class="post-metadata">

**Author:** ![grace](https://talk.openmrs.org/user_avatar/talk.openmrs.org/grace/32/16942_2.png) [@grace](https://talk.openmrs.org/u/grace)\
**Post date:** [February 14, 2025, 7:20pm UTC](https://talk.openmrs.org/t/how-to-lock-a-field-in-an-hfe-registration-form/44930/4 "2025-02-14T19:20:04Z")

</div>

Thank you very, very much Ian and Ellen for these fast and helpful answers! \<3
