This is a simple solution for create multiple accounts at a time.
public class multiAccountInsert{
public List<Account> accts {get; set;}
public multiAccountInsert(){
accts = new List<Account>();
accts.add(new Account());
}
public void addrow(){
accts.add(new Account());
}
public PageReference save(){
insert accts;
PageReference home = new PageReference('/001/o');
home.setRedirect(true);
return home;
}
}
<apex:page controller="multiAccountInsert">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" rerender="error"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!accts}" var="a" id="table">
<apex:facet name="footer">
<apex:commandLink value="Add Row" action="{!addRow}" rerender="table,error"/>
</apex:facet>
<apex:column headerValue="Name">
<apex:inputField value="{!a.Name}"/>
</apex:column>
<apex:column headerValue="Billing City">
<apex:inputField value="{!a.BillingCity}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
