+ Start a Discussion
Chris987654321Chris987654321 

Cannot edit fields on my VF page

I am having a problem with the following code. My problem is that some of the fields are able to be edited and saved and some are not. My goal here is just  have a VFpage where the uses can edit these records and save them using the My Save button. 

 

But if I change the fields and try to save, some of them save and some of them don't. Am I doing something wrong?

 

Controller code:

 

public class RasmussenEnrollmentClass_Ver3 { // Declare standardController controller private ApexPages.StandardController controller; private EA__c enrollment; // Will help us determine whether to do Insert or Update upon Save private Boolean bUpdate; public RasmussenEnrollmentClass_Ver3(ApexPages.StandardController stdController) { this.controller = stdController; this.enrollment= (EA__c)stdController.getRecord(); //if the pos.id is null that means this is an insert of a new obj, not and edit bUpdate = enrollment.id == null ? false : true; } public PageReference myEA() { if ([select Id FROM EA__c WHERE Student_Name__c=:userinfo.getuserid()].size() > 0) { EA__c eaID= [select Id FROM EA__c WHERE Student_Name__c=:userinfo.getuserid()]; PageReference pg= new PageReference('/apex/RasEA_1?id='+eaId.Id); pg.setRedirect(true); return pg; } else { //If size is 0 it means there is no Enrollment Agreement record. The admin assistant did not make one yet. //In this case, redirect the user to a page which says to please wait while their EA is processed PageReference pg1= new PageReference('/apex/NoEnrollment'); pg1.setRedirect(true); return pg1; //This was just a test for trying to let the student do a blank form if the EA was not created by the Admin yet //The following should not be used // PageReference pg= new PageReference('/apex/RasmussenEnrollmentPage_Fix?id='+eaId.Id); /// PageReference pg= new PageReference('/apex/RasEA_1'); // pg.setRedirect(true); // return pg; } } public PageReference mySave(){ // This is contrived unless there is something to do special in the update or insert you're trying to do // if you're not doing anything special in the save then just use the standardController.save() // if (bUpdate){ try { update enrollment; } catch(System.DMLException e) { ApexPages.addMessages(e); System.debug(e); return null; } return null; } }

 

 VF Page

 

<apex:page sidebar="false" showHeader="false" standardController="EA__c" extensions="RasmussenEnrollmentClass_Ver3"> <apex:form id="theForm"> <apex:pageBlock > <apex:pageBlockButtons > <apex:commandButton value="My Save" action="{!mySave}"/> <apex:commandButton value="Cancel" action="{!cancel}" immediate="true"/> </apex:pageBlockButtons> <apex:pageBlockSection columns="2"> <apex:inputField id="FirstName" value="{!EA__c.First_Legal_Name__c}" required="FALSE"/> <apex:inputField id="LastName" value="{!EA__c.Last_Legal_Name__c}" required="FALSE"/> <apex:inputField id="SSN" value="{!EA__c.Social_Security_Number__c}" required="FALSE"/> <apex:inputField id="DOB" value="{!EA__c.Date_of_Birth__c}" required="FALSE"/> <apex:inputField id="Phone" value="{! EA__c.Phone_Number__c}" required="FALSE"/> <apex:inputField id="Phone2" value="{! EA__c.Secondary_Phone__c}" required="FALSE"/> <apex:inputField id="Address1" value="{! EA__c.Address_1__c}" required="FALSE"/> <apex:inputField id="Address2" value="{! EA__c.Address_2__c}" required="FALSE"/> <apex:inputField id="City" value="{! EA__c.City__c}" required="FALSE"/> <apex:inputField id="Country" value="{! EA__c.Country__c}" required="FALSE"/> <apex:inputField id="Email" value="{! EA__c.Email__c}" required="FALSE"/> <apex:inputField id="Maiden" value="{! EA__c.Maiden_Name__c}" required="FALSE"/> <apex:inputField id="Phone3" value="{! EA__c.Phone__c}" required="FALSE"/> <apex:inputField id="State" value="{! EA__c.State__c}" required="FALSE"/> <apex:inputField id="Zip" value="{!EA__c.Zipcode__c}" required="FALSE"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
dev_forcedev_force

Maybe the issue is some of your merge fields have spaces?

e.g.

value="{! EA__c.Address_1__c}"

 should be

 

value="{!EA__c.Address_1__c}"

 

All Answers

dev_forcedev_force
Why don't you call the standard controller save method? {!save}
Chris987654321Chris987654321

Because the standard Save goes to the Detail View page after saving which I don't want the Customers to see in the Customer Portal. I want it to stay on the same page so I return null for the PageReference.

 

 

However, I did try using the standard Save as a test and got the same exact problem.

Message Edited by Chris987654321 on 03-27-2009 07:22 AM
dev_forcedev_force

Maybe the issue is some of your merge fields have spaces?

e.g.

value="{! EA__c.Address_1__c}"

 should be

 

value="{!EA__c.Address_1__c}"

 

This was selected as the best answer
Chris987654321Chris987654321
Thank you Dev_Force. That's what it was. I feel so stupid! :)