[SalesForce] Disabled attribute not present for apex:inputfield. Any alternatives

Unlike for components such as apex:selectList, apex:inputText etc., apex:inputField doesn't provide a Disabled attribute which is unfortunately exactly what I need right now.
Could there be any alternatives here?

I need an inputfield to remain disabled until a value in selectList != '–None–'. How can I achieve this if, in the code below, I were to replace apex:inputText with apex:inputField . This code is TWO steps away from my need i.e. it uses inputText and when the page loads Name is still not disabled even though selectlist has "–None–" as value.

enter image description here

Any insights/help will be greatly appreciated. Thanks!!

Best Answer

In your VF page, use both components, inputField and outputField with opposite rendering condition. What you have to pay attention to is to update the components everytime an action specified in actionSupport is called. You can do so by wrapping both inputField and outputField components in an outputPanel and specifying the outputPanel's ID as the element to rerender on actionSupport's finish.

<apex:selectList id="birthPlace" value="{!birthPlace}">
    <apex:selectOption itemLabel="--None--" itemValue="none" />
    <apex:selectOption itemLabel="Poland" itemValue="pld" />
    <apex:selectOption itemLabel="Europe" itemValue="erp" />
    <apex:actionSupport event="onchange" action="{!boolChange}" rerender="nameFields" />
</apex:selectList>
<apex:outputPanel id="nameFields">
    <apex:outputField label="Name" value="{!Chopin}" rendered="{!pianoBool}" />
    <apex:inputField label="Name" value="{!Chopin}" rendered="{!NOT(pianoBool)}" />
</apex:outputPanel>


Hope it helps!