function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Patricia LimPatricia Lim 

VF - <apex:form> not inserting records after hitting save

Hi all. I have a VF page with an <apex:form> component with Account as the standard controller however when I enter details and click save in the preview page or on the community where I placed it as a component, it doesn't add the record to my Salesforce org - what am I missing here?
 
<apex:page standardController="Account">
    <h1>Enter Account</h1>
    <apex:form >
    <apex:pageBlock title="Edit Account">
        <apex:pageBlockSection columns="2">
            <apex:inputField value="{! Account.Name}"/>
            <apex:inputField value="{! Account.Phone}"/>
            <apex:inputField value="{! Account.Industry}"/>
        </apex:pageBlockSection>
        <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="Save"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>
</apex:page>

Thanks
SwethaSwetha (Salesforce Developers) 
HI Patricia,
I have done a quick repro on my dev org with the code provided and could see a new account created in the VF page's preview mode.
To troubleshoot further,check following:

Do you have any pop up blocker enabled because of which you are not getting redirected to newly created account?

Can you enable debug logs in your org and see if there are any error messages?

Thanks
Dushyant SonwarDushyant Sonwar
Add apex:pageMessages in your code , this will tell you what is causing the issue.

Your final code will be like this
<apex:page standardController="Account">
    <h1>Enter Account</h1>
    <apex:form >
    <apex:pageBlock title="Edit Account">
        <apex:pagemessages id="pg"/>
        <apex:pageBlockSection columns="2">
            <apex:inputField value="{! Account.Name}"/>
            <apex:inputField value="{! Account.Phone}"/>
            <apex:inputField value="{! Account.Industry}"/>
        </apex:pageBlockSection>
        <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="Save"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>
</apex:page>

Hope this will help!
Dushyant SonwarDushyant Sonwar
Patrica,

Did it resolved your issue?