Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How to create readonly input text field where it should go as form data
we have two different ways to achieve this with plain HTML <input> tag
1. readonly attribute - where text field value will go in form data when user submits a form
2. disabled attribute - doesn't go with form dataas for as I checked with AUI library and gone through other community posts, we have only disabled attribute option.
I have a situation with input field that will be readonly on certain condition and it should go with formdata when I submit the form.
and I have aui required validator on it when it's not readonly.
Need help here.
Thanks
1. readonly attribute - where text field value will go in form data when user submits a form
2. disabled attribute - doesn't go with form dataas for as I checked with AUI library and gone through other community posts, we have only disabled attribute option.
I have a situation with input field that will be readonly on certain condition and it should go with formdata when I submit the form.
and I have aui required validator on it when it's not readonly.
Need help here.
Thanks
Hi,
You can use Custom Aui Validator like this
<aui:validator name="custom" >
function(val,fieldNode,ruleValue) {
//Your Logic
return true;
}
</aui:validator>
You can use Custom Aui Validator like this
<aui:validator name="custom" >
function(val,fieldNode,ruleValue) {
//Your Logic
return true;
}
</aui:validator>
Hi Chetan,It's necessarily the most elegant, but you could manage this with a hidden field that has the same value as the disabled field. Alternatively, you the <input type="text"/> with the disabled attribute and just name sure you <portlet:namespace/>myVariable on the name so that the portlet namespace is added. One trick I have used in the past is to use the <aui:input/> tag ... deploy it .. and then in the browser use the inspector to grant the markup Liferay generated. That way it renders the same as the other <aui:input/> fields on your form. Just make sure, as I mentioned, that you replace the name copied from the browser with the namespace.
For readonly, what I usually do is add a hidden input for the real value to be submitted in the form. Then I just use normal html to display what you want the user to see or <aui:input type="resource".../> if you want it easily copy/pastable.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™