You need to sign in to do that
Don't have an account?
Andrew Hoban 6
VisualForce page wont save with Controller extension
Hi all,
I have created a visualforce page that allows multiple rows of the same fieldto be added on the page.
However when i try to save the record, the page refreshes but does not save. I am not sure if I have to create a custom save method or weather I can use the one provided with the standard controller.
My controller is:
VF Page:
Thanks
I have created a visualforce page that allows multiple rows of the same fieldto be added on the page.
However when i try to save the record, the page refreshes but does not save. I am not sure if I have to create a custom save method or weather I can use the one provided with the standard controller.
My controller is:
public class IncidentLogPopup { public List<Incident_Log__c> memberList {get;set;} public List<Incident_Log__c> memberAddList {get;set;} public String memberName {get;set;} public IncidentLogPopup(ApexPages.StandardController controller) { String sql = 'SELECT Date_Time__c, Incident__c, Reported_to__c, Reported_By__c FROM Incident_Log__c'; memberList = Database.Query(sql); memberAddList = new List<Incident_Log__c>(); memberAddList.add(new Incident_Log__c()); } public void AddRow() { memberAddList.add(new Incident_Log__c()); } }
VF Page:
<apex:page sidebar="false" StandardController="Incident_Log__c" extensions="IncidentLogPopup"> <apex:form > <apex:pageBlock id="membAdd" > <apex:pageBlockButtons location="Both"> <apex:commandButton value="Save" Action="{!save}" /> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:pageblockSection > <apex:pageBlockTable value="{!memberAddList}" var="memb"> <apex:column headerValue="Date/Time"> <apex:inputField value="{!memb.Date_Time__c}"/> </apex:column> <apex:column headerValue="Incident"> <apex:inputField value="{!memb.Incident__c}"/> </apex:column> <apex:column headerValue="Reported To"> <apex:inputField value="{!memb.Reported_To__c}"/> </apex:column> <apex:column headerValue="Reported By"> <apex:inputField value="{!memb.Reported_By__c}"/> </apex:column> </apex:pageBlockTable> <br/><apex:commandLink value="Add Row" action="{!addRow}" /> </apex:pageblockSection> <apex:pageblockSection columns="1" > <apex:pageblockSectionItem > </apex:pageblockSectionItem> </apex:pageblockSection> </apex:pageBlock> </apex:form> </apex:page>
Thanks
James is 100% correct.
Use the easier approach override the save method in extension.
Copy and paste this method in your Extension
i.e.
All Answers
You can try playing around with the recordSetVar attribute to see if that will allow you to insert your multiple records. I think the easier approach though is to override the save method in your extension, and then insert (or upsert?) the list of records.
Thanks
James is 100% correct.
Use the easier approach override the save method in extension.
Copy and paste this method in your Extension
i.e.
And please mark them as solution so if anyone else face the same problem so they got the solution easyly.