- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2016 06:22 AM
So, I have a UI Page with a <g:ui_form> and a single <g:ui_reference> field. What's the best way to set such a field to read-only? I've tried the readonly HTML attribute to no avail.
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2016 07:51 AM
For <g:ui_form>, that element doesn't take the read-only attribute as it doesn't directly take any input. However, it contains input elements that will take input from the user but those have to be set individually and not through the form element.
For <g:ui_reference>, one way you can set this to read-only is by passing it a name which when rendered will produce an id for the element more than likely with a "sys_display." prepended to the name you gave it.
From there, either in the html/xml field of the UI page or in the client script field create a script that will grab the element and set it to read-only.
For example:
HTML/XML:
<g:ui_reference name="my_ref" table="sys_user" />
Client Script:
var ro = gel('sys_display.my_ref');
ro.readOnly = true;
Note: Doing this will make the input field itself read-only. It won't stop the user from using the lookup icon to select a record. For that you may have to hide the lookup icon, remove the function on the onclick attribute, or other method.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2016 08:23 AM
Is this possible to make read only the reference field in ui page on load?
Abdul Fathah
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.