I have a pageblock table and I enabled InlineEditingSupport. However, everytime I edit it and click quick save, the last row is the only record that is being updated. I tried making my own method but I don't think I am getting it right.
VF PAGE
<apex:pageBlock title="Tiers">
<p style="font-size: 150%;"><b>Quote Number:</b> {!SBQQ__Quote__c.Name}</p><br/><br/>
<apex:pageBlockTable value="{!existingTiers}" var="tiers">
<apex:column headerValue="Tier Start" value="{!tiers.Tier_Start__c}"/>
<apex:column headerValue="Tier End" value="{!tiers.Tier_End__c}"/>
<apex:column headerValue="PMPM" value="{!tiers.Price__c}"/>
<apex:inlineEditSupport/>
</apex:pageBlockTable>
<apex:commandButton value="Quick Save" Action="{!Quicksave}"/>
</apex:pageBlock>
<apex:pageBlock title="Add Tiers">
<table>
<tr>
<th>Tier Start</th>
<th>Tier End</th>
<th>PMPM</th>
</tr>
<apex:repeat value="{!listTier}" var="Addtier">
<tr>
<td class="withborder" style="width: 15%;"><apex:inputField value="{!Addtier.Tier_Start__c}" /></td>
<td class="withborder" style="width: 15%;"><apex:inputField value="{!Addtier.Tier_End__c}" /></td>
<td class="withborder" style="width: 30%;"><apex:inputField value="{!Addtier.Price__c}" /></td>
</tr>
</apex:repeat>
</table>
<apex:commandButton value="Add" Action="{!add}"/>
<apex:commandButton value="Save" Action="{!Save}"/>
<apex:commandButton value="Cancel" Action="{!cancel}"/>
</apex:pageBlock>
</apex:form>
CONTROLLER
public class Quote_AdditionalTiersController {
ApexPages.StandardController sController;
public SBQQ__Quote__c getQuote{get; set;}
public Additional_Tier__c setAT{get; set;}
public List<Additional_Tier__c> listTier{get; set;}
public List<Additional_Tier__c> existingTiers{get; set;}
public Quote_AdditionalTiersController(ApexPages.StandardController sc){
sController = sc;
this.getQuote = (SBQQ__Quote__c)sc.getRecord();
setAT = new Additional_Tier__c();
listTier = new List<Additional_Tier__c>{
new Additional_Tier__c(Quote__c = getQuote.Id)
};
existingTiers = [SELECT Id, Quote__c, Tier_Start__c, Tier_End__c, Price__c FROM Additional_Tier__c WHERE Quote__c =: getQuote.Id];
}
public void add(){
listTier.add(new Additional_Tier__c(Quote__c = getQuote.Id));
}
public PageReference save() {
// setAT.Quote__c= getQuote.Id;
List<Additional_Tier__c> newTier = new List<Additional_Tier__c>();
for(Additional_Tier__c tier: listTier){
if(tier.Tier_Start__c != null && tier.Tier_End__c != null && tier.Price__c != null ){
newTier.add(tier);
}
}
insert newTier;
return new PageReference ('/'+getQuote.Id);
}
public PageReference Quicksave(){
sController.save();
PageReference pr = new PageReference('/apex/Quote_AdditionalTiers?id='+sController.getId());
pr.setRedirect(true);
return pr;
}
}