function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ScottPJScottPJ 

Dynamically setting fields to be Read-Only in a Visualforce page using a Custom Controller

I would ike to dynamically set fields to be read-only (based on another field value) in a Visualforce page using a Custom Controller.

 

Does anyone have any ideas on how to do this?

 

 

 

 

VisualForceVisualForce

Hi...

 

Use 'disabled' attribute with ur  component..

 

<apex:inputtext value="{!inp1}" disabled="{!flag}"/>

<apex:inputtext value="{!inp2}" >

<apex:actionsupport event="onchange" action="{!settingflag}"/>

</apex:inputtext>

 

In ur controller set ur flag value

 

 

ScottPJScottPJ

Hi,

 

Do you know if this works for a <apex:inputField component?   

ScottPJScottPJ

This property (Disabled) is not an attribute of the <apex:inputField component>.   Does anybody have any idea on how to make fields read-only during run-time?

 

VisualForceVisualForce

Hi..

 

     Convert inputfiled into inputtext..

ScottPJScottPJ

Hi,

 

How do you covert a PickList or Lookup to a InputText (from a InputField) and still retain the functionality?   Does anyone have any examples?

 

Thanks.

TehNrdTehNrd
What you can do is have two fields, and input and an output field that are bound to the same variable/object. You can then use the rendered tag on these to show and hide one field at a time.