function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Carly Probasco 14Carly Probasco 14 

How to make a picklist field read only in lighting component?

I have a picklist field that i would like to make read only on a edit screen.
 
<lightning:select name="classroomStatusSelect" label="Status:" value="{!v.SelectedClassroom.Status__c}" required="true" readonly="true">
      <aura:iteration items="{!v.ClassroomStatusOptions}" var="classroomStatus">
		<option text="{!classroomStatus}"></option>
</aura:iteration>
					</lightning:select>
What am i doing wrong?
 
Best Answer chosen by Carly Probasco 14
Carly Probasco 14Carly Probasco 14
I ended up creating formula text fields to display the picklist value. 

I'm an admin wading in developer waters and fell back on configuration skills.

All Answers

ANUTEJANUTEJ (Salesforce Developers) 
Hi Carly,

Can you try checking the below link as the readonly attribute was not working and he tried disabled attribute, let me know if this helps and in case if this comes in handy can you please choose this as best answer so that it can be used by others in the future.

Link: https://salesforce.stackexchange.com/questions/156204/readonly-property-of-lightninginput-not-working

Regards,
Anutej 
AnudeepAnudeep (Salesforce Developers) 
Hi Carly - I tried this in my org with a simple component and I have noticed the same behavior
 
<aura:component>
    <lightning:select name="selectItem" label="Select an item" onchange="{!c.doSomething}" disabled="true">
        <option value="">choose one...</option>
        <option value="1">one</option>
        <option value="2">two</option>
    </lightning:select>
</aura:component>

I checked and found out that a bug was already logged with Salesforce product team (W-4703044) in the past and they have specified this behavior as working as designed. However, seems like the documentation is yet to be updated to remove this field

Technical select does not have a read only attribute. The reason is that lists don't have values... they have selected options, which themselves have values

Using 'readonly' for the 'select' is not the valid use case. We can instead have an 'input' field if the value has to be read-only.

I tried disabled="true" and it disables the picklist field 

User-added imageI suggest logging a case with support. I will check on this internally from my end as well

Let me know if this helps
Carly Probasco 14Carly Probasco 14
I ended up creating formula text fields to display the picklist value. 

I'm an admin wading in developer waters and fell back on configuration skills.
This was selected as the best answer