You need to sign in to do that
Don't have an account?

Very simple visualforce form and custom controller not working
I'm trying to create a very simple visualforce form, that just doesn't seem to be working and I don't know why
VF:
<apex:page controller="SubmitReferralController" standardStylesheets="false" showHeader="false" sidebar="false"> <apex:stylesheet value="{!$Resource.semantic}"/> <html lang="en"> <head> </head> <body> <div style="margin-left:200px"> <h1>Referrals Fee Program</h1> <p> Any questions? Contact the <a href="semantic-form.css">Referral team</a>. </p> </div> <apex:form styleClass="semantic"> <apex:pageBlock > <div style="margin-left:200px"> <apex:outputPanel > <div> <apex:outputlabel Value="First Name"></apex:outputlabel> <apex:inputText value="{!c.FirstName}" size="30" id="referrer_first_name"/> <apex:outputlabel Value="Last Name"></apex:outputlabel> <apex:inputText value="{!c.LastName}" size="30" id="referrer_last_name"/> </div> <div style="margin-left:200px"> <apex:commandButton value="Submit Referral" action="{!submitReferral}"/> </div> </apex:outputPanel> </div> </apex:pageBlock> </apex:form> </body> </html> </apex:page>
Controller:
public class SubmitReferralController { public Contact c { get; set; } public PageReference submitReferral(){ try { insert c; } catch(System.DMLException e) { ApexPages.addMessages(e); return null; } return null; } }
I'm sure it's something really stupid, but I just can't sort it out.
Any help would be greatly appreciated!
What would that look like? Sorry, I'm still learning!
I would make changes to the Custom controller as shown below:
I have added the constructor and modified the insert to upsert (both underlined above)
You can refer the following links for more information:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_custom.htm
Developers Guide:
http://www.salesforce.com/us/developer/docs/pages/salesforce_pages_developers_guide.pdf
VisualForce Workbook:
http://www.salesforce.com/us/developer/docs/workbook_vf/workbook_vf.pdf