I am using the below code to set the field as read only in portal form
Anyone else experiencing this issue?
Any suggestions / help would help!!
Hope this helps someone who searches for the same issue in the future. I found instead of hiding, it works better to just change the muted text color to transparent:
$(".text-muted").css("color","transparent");
Thx to Muhammad. His Solution works and the "-" not showing after read-only is set.
@Kanagaraj Pandian Please mark his answer as verified.
I was facing the same issue, I have used the following workaround.
(I faced this issue when bringing out the code, for making the field read-only, outside of a sync js API call)
As you've discovered, the dash (text-muted div) appears because the field is marked as read-only. This is done by some JavaScript included as part of the Portal product. It will only add that the dash if your input is read only and has no value when the code is run.
If I had to guess, you're not putting your code that sets it to read only in a $(document).ready. This means your code is running before the code that handles the read-only functionality.
So you've got a couple options:
1. Set the value of the input before you set it as read only.
2. If you don't want that out of the box functionality, set it to be read only after that logic has already run by putting your code in a $(document).ready() like so:
$(document).ready(function() {
$("#serialnumber").attr("readonly", true);
});
Then, when the out of the box code runs, the field won't be read only yet, and the text-muted div won't be added.
Hope that helps.
Nick
Hi Oliver,
Making readonly is not an issue. The issue is when we make the field as readonly on create form, we are getting dash(-) along with the value. After saving the record the dash is not showing. I used the below code to remove dash from the field
$("#.text-muted").hide();
But, after that we are not able to select the lookup field also. Don't know how to hide "text-muted" class from the particular field.
Hi Kanagaraj,
One possible reason could be these fields may be read-only in entity forms as well. I was facing some issue like this but I have removed the div which contains the hyphens using below code:
$("#serialnumber").next("div").remove();
your code works fine for me.. very odd, can you try the following:
$("#serialnumber").attr("readonly", true);
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156