I've created a simple VFP that uses an apex:repeat to render a list of custom objects. These objects are displayed as a preview image with a quantity field. This is going to be used to allow people to order any number of each of the items from the same page. These items are simple promotional items so think of things like pens, notebooks, water bottles, etc.
The controller for the VFP creates a List property to populate the repeat. This part works fine. However the command button I added doesn't appear to save the records.
What am I doing wrong here? It seems like it should be pretty straightforward since I already have a handle on the list of objects that were rendered.
The controller code:
public class Promo_Controller {
public List<Promotional_Item__c> promoItems{
get { return promoItems;} set { promoItems = value;}
}
public Promo_Controller(){
this.promoItems = new List<Promotional_Item__c>();
this.promoItems = [Select Name, Quantity__c, Description__c, Image__c, Type__c FROM Promotional_Item__c ORDER BY Type__c];
}
public void submitOrder(){
update this.promoItems;
}
And the VFP:
<apex:form styleClass="body" id="promoItemForm">
<apex:repeat value="{!promoItems}" var="curItem" id="rptPromoItems" >
<apex:image styleClass="preview {!curItem.Type__c}" url="{!curItem.Image__c}"/>
<apex:outputText styleClass="titleBox" value="{!curItem.Description__c}" id="desc"/>
<apex:inputText styleClass="quantity" value="{!curItem.Quantity__c}" id="count" size="1"/>
</apex:repeat>
<apex:commandButton id="submit" action="{!submitOrder}" value="Order"/>
</apex:form>
EDIT: removed the immediate="true" as suggested.
immediate="true"
and try saving the records.immediate=true
. As battery said, remove that and try it.Promo_Controller
name is different than class nameListrak_UPS_Promo_Controller
.