15

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

2 Answers 2

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.

1
  • 2
    I think you mean to use "rendered" instead of "reRender"
    – DaveS
    Commented Apr 12, 2015 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .