15

apex:inputField does not have an attribute called disabled. How can I get an apex:inputField to be disabled?

15

An easy and always work workaround:

<apex:outputPanel rendered="{!onOff}">
    <apex:inputField value="{!someField}"/>
</apex:outputPanel>
<apex:outputPanel rendered="{!NOT(onOff)}">
    <apex:outputField value="{!someField}"/>
</apex:outputPanel>

With a {!onOff} variable and reRender behavior, the field behavior can be controlled just as you actually need.

  • 2
    I think you mean to use "rendered" instead of "reRender" – DaveS Apr 12 '15 at 0:24
9

The reason is because this component responds to the read-only state of the field it is bound to (for example if the users profile does not permit editing of the field) via the value attribute.

Note: Read-only fields, and fields for certain Salesforce objects with complex automatic behavior, such as Event.StartDateTime and Event.EndDateTime, don't render as editable when using . Use a different input component such as apex:inputText instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.