You need to sign in to do that
Don't have an account?

How to make field readonly in VF page based on picklist value
Hi,
I haev on requirement like if user selects picklist value to Closed all the fields makes readonly except 2 fields.
I used output field with rendered - But field is hiding in page if not matching the condition.
How do I achive this?
My Code :
<apex:sectionHeader title="IBX Lines Edit" subtitle="{!IBX_Lines__c.name}"/> <apex:form > <apex:pageBlock mode="edit" id="pgBlockId"> <apex:pageMessages escape="false" /> <apex:pageBlockButtons location="both"> <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Save & New" action="{!save}" /> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Information" columns="2"> <apex:inputField value="{!IBX_Lines__c.Name}" required="false"/> <apex:inputField value="{!IBX_Lines__c.CurrencyIsoCode}" required="false"/> <apex:inputField value="{!IBX_Lines__c.Opportunity__c}" required="true"/> <apex:inputField value="{!IBX_Lines__c.Primary_Campaign_Source__c}" required="false"/> <apex:pageBlockSectionItem > <apex:outputLabel value="IBX Name" for="stage"/> <apex:actionRegion > <apex:inputField value="{!IBX_Lines__c.IBX_Name__c}" required="true" id="stage"> <apex:actionSupport event="onchange" reRender="dependentPick" action="{!getCompetitorsFromIBX}"/> </apex:inputField> </apex:actionRegion> </apex:pageBlockSectionItem> <apex:inputField value="{!IBX_Lines__c.Lead_Source__c}" required="false"/> <apex:inputField value="{!IBX_Lines__c.Line_Type__c}" required="true"/> <apex:inputField value="{!IBX_Lines__c.Cross_Region_Lead_Source__c}" required="false"/> <apex:inputField value="{!IBX_Lines__c.Adjustment_Type__c}" required="false"/> </apex:pageBlockSection> <apex:pageBlockSection title="Status" columns="1"> <apex:inputField value="{!IBX_Lines__c.Forecast_Status__c}" required="false"/> <apex:inputField value="{!IBX_Lines__c.Lost_Reason__c}" required="false"/> <apex:inputField value="{!IBX_Lines__c.Closed_Won_Lost_Notes__c}" required="false"/> </apex:pageBlockSection> <apex:pageBlockSection title="MRR/NRR" columns="2"> <!--<apex:inputField value="{!IBX_Lines__c.Forecast_MRR__c}" required="true"/>--> <apex:outputField value="{!IBX_Lines__c.Forecast_MRR__c}" rendered="{!(IBX_Lines__c.Forecast_Status__c='Slipped')}" /> <!--<apex:outputField value="{!IBX_Lines__c.Forecast_MRR__c}" rendered="{!(IBX_Lines__c.Forecast_Status__c=='Active')}" />--> <apex:inputField value="{!IBX_Lines__c.Forecast_NRR__c}" required="true"/> <!-- <apex:inputField value="{!IBX_Lines__c.Booked_Gross_MRR__c}" required="false"/> <apex:inputField value="{!IBX_Lines__c.Booked_Gross_NRR__c}" required="false"/> <apex:inputField value="{!IBX_Lines__c.Booked_Net_MRR__c}" required="false"/> <apex:inputField value="{!IBX_Lines__c.Booked_Net_NRR__c}" required="false"/> --> </apex:pageBlockSection> <apex:pageBlockSection title="Competitors" columns="2" > <!-- Temporarily commented out by SD --> <c:MultiselectPicklist leftLabel="Available Competitors" id="dependentPick" leftOptionsName="{!allCompetitors}" rightLabel="Selected Competitors" rightOptionsName="{!selectedCompetitors}" size="14" width="150px"/> <apex:inputHidden value="{!IBX_Lines__c.Competitors__c}" required="false"/> </apex:pageBlockSection> <apex:pageBlockSection title="Comments" columns="1"> <apex:inputField value="{!IBX_Lines__c.Comments__c}" required="false"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
the rendered condition used by you will hide the field if the condition mathches.
I think you do not need rendered condition int he outputfield .
Otherwise try outputtext without any rendered.
Thanks for your reply....
How I can I match the condtion. If picklist value =" ClosedLost" then all the fields readonly except 2 fields otherwise editable.
Please post me the correct solution..