Multiple bindings to the same record

A very common problem in Visualforce is inadvertently binding multiple <apex:inputField /> components to the same sObject record and field instance. In the following example markup, the StageName field of each opportunity record has been bound to two separate input fields - the first intended to display the name of the current stage and the second to allow the user to supply the name of the desired stage.

<apex:form > <apex:pageBlock > <apex:pageBlockTable value="{!opps}" var="opp"> <apex:column headerValue="Name"> <apex:inputField value="{!opp.Name}" /> </apex:column> <apex:column headerValue="Stage Name"> <apex:inputField value="{!opp.StageName}" /> </apex:column> <apex:column headerValue="Amount"> <apex:inputField ...

Get Visualforce Development Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.