I have a output view page, and i want to insert a edit command button. when user click on edit button it will enable them to type on output field and save. Can anybody tell me how to do that? Thanks

<apex:page standardController="Product_Brief__c" sidebar="true" showHeader="true" extensions="gibco" ><br/>
<apex:form ><br/>
            <apex:pageBlock mode="inlineEdit"><br/>
            <apex:pageBlockSection collapsible="false" title="Section 1: Custom Media Information (Required)"><br/>
                <apex:outputField value="{!Product_Brief__c.Opportunity__r.Account.Name}"  Label="Company Name"/><br/>
                <apex:outputField value="{!Product_Brief__c.Customer_Number__c}" label="Customer Number"/><br/>
                <apex:outputField value="{!Product_Brief__c.Billing_Address__c}" /><br/>
                <apex:outputField value="{!Product_Brief__c.CreatedBy.Name}"  Label="Contact Name"/><br/>
                <apex:outputField value="{!Product_Brief__c.Shipping_Address__c}"/>

<apex:pageblockButtons ><br/>
                <apex:commandButton action="{!save&view}" value="SAVE"/><br/>
                <apex:commandButton value="PRINT" onclick="window.print();"/><br/>
                <apex:commandButton value="Cancel" action="{!Cancel}"/><br/>
  • Do you really need a button? Why not use inline edit, where for example: you can double click on the output field and it converts to an input field so the value can be changed – navD87 Jun 19 '15 at 20:11
  • Actually I want a button. Because this is customer facing form, so they want it like a input field. Any idea? – Dananjaya Pathirana Jun 19 '15 at 20:13
  • For a pure VF solution, if you don't like inlineEdit, you'll need pair of apex:inputField/apex:outputField for every potentially editable fields, conditionally rendered based on whether edit button was clicked or not. The edit button's action tells the controller if clicked – cropredy Jun 20 '15 at 0:19
  • Is there one button per field, or will the button make all fields editable at the same time? – martin Jun 20 '15 at 8:30
  • Take a look at this question here, it might help point you in the right direction salesforce.stackexchange.com/questions/45432/… – Jenny B Jun 20 '15 at 11:30

please take a look at this post https://salesforce.stackexchange.com/a/80796/21026 for the requirement was the same as yours.

See you

  • Thank you Julien Gaïotto. it works the way i want it now. – Dananjaya Pathirana Jun 22 '15 at 15:29
  • Well I didn't see you were the author of the first post haha, sorry for the duplicate answer – Julien Gaïotto Jun 22 '15 at 15:31
  • No problem. Its all good. – Dananjaya Pathirana Jun 22 '15 at 15:38
  • Hey Julien, I have a another problem. If I have two view page I do I connect each other with this code. I mean when I click edit I would be able to edit both page and save. Do you have any idea? Thanks – Dananjaya Pathirana Jun 23 '15 at 15:16

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.