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

what am i missing because its still not letting me save the record ?
<apex:page controller="worldcup">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputField value="{!wc.Name}"/>
<apex:inputField value="{!wc.who_is_going_to_win__c}"/>
<apex:commandButton action="!{Save}" value="save"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
this is my VF page and the method i have used is :
public class worldcup {
public worldcup() {
}
public WorldCup__c wc;
public worldcup (ApexPages.StandardController controller) {
this.wc = (WorldCup__c)Controller.getRecord();
}
public WorldCup__c getwc(){
return wc;
}
Public PageReference save(){
WorldCup__c wc=[Select id,Name, who_is_going_to_win__c From WorldCup__c];
upsert wc;
return null;
}
}
after i submitted a record on the VF page i recieved an error saying Formula Expression is required on the action attributes. am i missing the save attribute ?
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputField value="{!wc.Name}"/>
<apex:inputField value="{!wc.who_is_going_to_win__c}"/>
<apex:commandButton action="!{Save}" value="save"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
this is my VF page and the method i have used is :
public class worldcup {
public worldcup() {
}
public WorldCup__c wc;
public worldcup (ApexPages.StandardController controller) {
this.wc = (WorldCup__c)Controller.getRecord();
}
public WorldCup__c getwc(){
return wc;
}
Public PageReference save(){
WorldCup__c wc=[Select id,Name, who_is_going_to_win__c From WorldCup__c];
upsert wc;
return null;
}
}
after i submitted a record on the VF page i recieved an error saying Formula Expression is required on the action attributes. am i missing the save attribute ?
<apex:page standardController="WorldCup__c">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputField value="{!WorldCup__c.Name}"/>
<apex:inputField value="{!WorldCup__c.who_is_going_to_win__c}"/>
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
</pre>
All Answers
<apex:commandButton action="!{Save}" value="save"/>
to
<apex:commandButton action="{!save}" value="save"/>
In the VF code, the error you're getting is because you have
action="!{Save}"
it should be
action="{!Save}"
Then, in the save method, you are querying the record, which will overwrite any input that the user has made. The record will be saved unmodified.
In fact, everything you want to do can be done using the standard controller. You don't need the "worldcup" class at all. The code in the next post shows how to do this.
Glyn Anderson
Sr Developer | System Analyst | ClosedWon | closedwon.com
Certified Developer | Certified Advanced Administrator
Blog: GlynATheApexGuy@blogspot.com
Twitter: @GlynAtClosedWon
<apex:page standardController="WorldCup__c">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputField value="{!WorldCup__c.Name}"/>
<apex:inputField value="{!WorldCup__c.who_is_going_to_win__c}"/>
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
</pre>
-Glyn