I have an object VF_Page_Update__c which has a picklist field called VF_Page_Picklist__c and a textArea(255) field Update__c. I am dynamically showing the picklist values in the Visualforce page I created called 'UpdatePageVF'. Now what I want is when I change the picklist value in VF_Page_Picklist__c and change the text in Update__c from the VF page and click on Save button, then that value will be updated in database. Currently, the VF_Page_Picklist__c value gets changed, but the value in Update__c remains the same old value even after clicking on Save. What am I doing wrong?
Apex class 'UpdateController'
public with sharing class Update_Controller {
public VF_Page_Update__c mcc {get; private set;}
private final VF_Page_Update__c speaker;
private ApexPages.StandardController stdController;
public Update_Controller(ApexPages.StandardController stdcontroller) {
mcc= [select Id,name,VF_Page_Picklist__c, Update__c from VF_Page_Update__c WHERE id = :ApexPages.currentPage().getParameters().get('id')];
this.speaker = (VF_Page_Update__c)stdController.getRecord();
this.stdController = stdController;
}
public List<SelectOption> getVFPageList()
{
List<SelectOption> options = new List<SelectOption>();
Schema.DescribeFieldResult fieldResult =
VF_Page_Update__c.VF_Page_Picklist__c.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry f : ple)
{
options.add(new SelectOption(f.getLabel(), f.getValue()));
}
return options;
}
public PageReference saveClose() {
update speaker;
return null;
}
}
Visualforce page 'UpdatePageVF'
<apex:page standardController="VF_Page_Update__c" extensions="Update_Controller" >
<apex:form >
<apex:pageBlock mode="edit">
<apex:pageMessages />
<apex:pageBlockSection columns="1" >
<apex:inputField value="{!mcc.Update__c}"/> <p/>
<apex:selectList id="countries" value="{!VF_Page_Update__c.VF_Page_Picklist__c}"
size="1" required="true">
<apex:selectOptions value="{!VFPageList}"/>
</apex:selectList>
<apex:commandButton value="Save" action="{!saveClose}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
This code only updates the VF_Page_Picklist__c but not the Update__c.Please help and provide me the corrected code if possible.