Activity Forums Salesforce® Discussions How to Pass the value of Apex:inputField to the extension controller of contact in Salesforce?

  • How to Pass the value of Apex:inputField to the extension controller of contact in Salesforce?

    Posted by Saravjeet on October 10, 2019 at 9:15 am

    Ho to Pass the value of Apex:inputField to the extension controller of contact.

    VF Page Code:
    <apex:page standardController="Contact" extensions="ReplacementContactController">
    <apex:form>
    <apex:pageBlock title="Contacts List" id="contacts_list">
    <apex:pageBlockSection>
    <apex:inputField value="{!Contact.Reason_Inactive__c}" />
    <apex:inputField value="{!Contact.Replacement_Contact__c}"/>
    </apex:pageBlockSection>
    <apex:pageBlockButtons>
    <apex:commandButton value="Save" action="{!SaveAction}"/>
    <apex:commandButton value="Cancel" action="{!Cancel}"/>

    </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form></apex:page>

    Controller code:

    public class ReplacementContactController {

    public Id cntId;
    public String reasonInactive{get;set;}
    public Contact contact{get;set;}

    public ReplacementContactController(ApexPages.StandardController controller) {
    cntId = controller.getId();
    }

    public void SaveAction() {
    Contact cnt = [SELECT FirstName, LastName, Title, Inactive__c,Reason_Inactive__c FROM Contact where Id =:cntId];
    cnt.Inactive__c = True;
    update cnt;
    }

    }

    ***************************************************************

    Problem is, I am not bale to pass the selected value for the 2 input fields to the controller

    • This discussion was modified 5 years, 2 months ago by  Saravjeet Singh.
    • This discussion was modified 4 years, 11 months ago by  Forcetalks.
    • This discussion was modified 4 years, 11 months ago by  Forcetalks.
    Saravjeet replied 5 years, 2 months ago 1 Member · 0 Replies
  • 0 Replies

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos

Popular Salesforce Infographics