You need to sign in to do that
Don't have an account?
Olivia Forde
readonly field on edit page
I have a Visualforce Edit Page and I want some of the fields to display readonlyI have tried this
<apex:outputfield value="{!Item.Item_Code__c}"/> but it only displays the label
<apex:outputfield value="{!Item.Item_Code__c}"/> but it only displays the label
Can you please share your Controller code with us?
Because you are using two objects
editItem
and
item
and try this
<apex:outputfield value="{!EditItem.Item_Code__c}"/>
With the URL of record on page
Sameer
All Answers
Use this
<apex:outputLabel value="SampleLabel"/>
<apex:outputText value="{!Item.Item_Code__c}"/>
Best Regards,
Mithun.
Tried this now but it displays the Label twice now but no data value for the field
It will show you only label of the read only field, If you are creating a record first time from your page because at that time value is not calculated.
However if you are editing the same record through your page and ID is mentioned in URL then you will be able to see Read only field value also
for Example
Your VF page name is myvfpage
You have read only field name is Item Code, which is an auto number type field or formula field.
You are creating record first time with this URL
https://finacastapp.ap1.visual.force.com/apex/myvfpage
then Item code is not generated, because it will generate if you save that record. At that time it will show you label only
Now your record is created and you are using this URL
https://finacastapp.ap1.visual.force.com/apex/myvfpage?id=906F0000000Adf
It will display you that read only field value on VF page.
Thanks & Regards,
Sameer Tyagi.
http://mirketa.com
Not sure why it is displaying two labels, can you share your code.
If you want label with value use pageBlockSection.
Best Regards,
Mithun.
<apex:outputfield value="{!Item.Item_Code__c}"/>
Sameer
<apex:pageBlockSectionItem helpText="Full Name of the Item to be added to GP and used on Invoices and Marketing Material">
<apex:outputLabel value="Item Name"/>
<apex:inputField value="{!editItem.Name}" required="true"/>
</apex:pageBlockSectionItem>
<apex:inputField value="{!editItem.Target_Cost_Price__c}" required="true"/>
<apex:outputLabel value="Item Code"/>
<apex:outputText value="{!Item.Item_Code__c}"/>
<apex:inputField value="{!editItem.Target_Cost_of_Goods__c}" required="true"/>
<apex:inputField value="{!editItem.SIGW__c}"/>
</apex:pageBlockSection>
Below is the updated version. I have tested in my org it's working fine.
Best Regards,
Mithun.
This is what I get
To test it you'll need the ID of one of your custom objects. If you open one the url will look something like this:
https://na3.salesforce.com/a0350000006VljmAAC
copy the 15-18 character id and append it to the url for your apex page, for example:
https://na3.salesforce.com/apex/myvfpage?id=a0350000006VljmAAC
and the tag you are using earlier was correct
<apex:outputfield value="{!Item.Item_Code__c}"/>
Is this what you were looking to accomplish Olivia?
Sameer
Yes I have tried that - the Item Code is visible when I open the Item but whi I hit Edit (which is my VF page) it displays only the label. I have even copied the code from the URL onto the Edit page but with the same result
Can you please share your Controller code with us?
Because you are using two objects
editItem
and
item
and try this
<apex:outputfield value="{!EditItem.Item_Code__c}"/>
With the URL of record on page
Sameer
Thats the solution - wrong controller. Many thanks :)