You need to sign in to do that
Don't have an account?
Simple VF page - standard Save action doesn't work
I have a very simple VF page:
<apex:page standardController="Opportunity">
<apex:pageMessages />
<apex:form >
Opp name: <apex:inputField value="{! Opportunity.Name }" />
<br/>
<apex:commandButton value="Save" action="{! save }" />
</apex:form>
</apex:page>
I log in as a System Administrator and load the page with this: https://c.cs1.visual.force.com/apex/Test?id=006S0000003Br7y
The page looks just fine. I type in a new Opportunity name and click Save. The page thinks a little, then redirects me to the regular Opportunity view page, but my new Opportunity name doesn't appear -- it's not getting saved.
I'm logged in as a System Administrator, so it shouldn't be a permissions issue. I can edit the Opp name using the standard edit page just fine, so again, I don't think it's related to permissions. I'm using the standard controller, although I've tried it with a custom controller, and I see the same results -- no error, but my changes don't get saved.
Any ideas?
Hello;
Try replacing
value="{! Opportunity.Name }" //There are extra spaces
With
value="{!Opportunity.Name}" //Extra spaces are removed
and
action="{! save }" //There are extra spaces
With
action="{!save}" //Extra spaces are removed
All Answers
Here you need to use an customcontroller.
<apex:page standardController="Opportunity" extenstions ="customcontroller">
<apex:pageMessages />
<apex:form >
Opp name: <apex:inputField value="{! Opportunity.Name }" />
<br/>
<apex:commandButton value="Save" action="{! save }" />
</apex:form>
</apex:page>
in the custom controller wrtie yours logic like this
using pageparameters get the vlaue to save using getter and setter methods ,and insert thave in opp.name field .you can get lot of example in the forum just tryit of intially go tthrough cookbook.
Hello;
Try replacing
value="{! Opportunity.Name }" //There are extra spaces
With
value="{!Opportunity.Name}" //Extra spaces are removed
and
action="{! save }" //There are extra spaces
With
action="{!save}" //Extra spaces are removed
Removing the spaces as prageeth suggested (thank you!) did the trick.
But why?
With the spaces in, the page displayed properly. I could see the current value of Opportunity.Name. The Save button did call the save() action, because it redirected me to the Opportuny view page when it was done.
I can understand why something like this:
value=" {!Opportunity.Name} "
with spaces outside the braces would cause problems. But if the spaces are inside the braces, why could that be a problem? Is this really expected / desired behavior?
Prageeth, thank you for your help!