+ Start a Discussion
adi salesforceadi salesforce 

how to make input field read only in vf page

There are two record types in account. using Trigger I'm populating account industry field from record type 1 to record type 2 Now I want to make account industry as read only field in record type2
Daniel Probert 10Daniel Probert 10
try putting html-disabled="true" if you are using <apex:inputField
Hi Adi,

Edit the page layout for the record Type 2, and make the field read only.

Please mark this solved, if it had helped you. Thanks!

Krishna Avva
Deepali KulshresthaDeepali Kulshrestha
Hi Adi,

To disable the input field using the attribute html-disabled=" true" in the input field.
You can use this code to check how it works here in the input field I have used the attribute HTML-disabled to disable the input field:

<apex:page standardController="Contact" recordSetVar="contacts">
    <apex:pageBlock title="Contacts List">
        <!-- Contacts List -->
        <apex:pageBlockTable value="{! contacts }" var="ct">
            <apex:column value="{! ct.FirstName }"/>
            <apex:column value="{! ct.LastName }"/>
            <apex:column >
                <apex:inputField value="{!ct.Email}" html-disabled="true"  />
            <apex:column value="{! ct.Account.Name }"/>

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha