function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jina ChetiaJina Chetia 

How do I use the same input field name more than once in a page?


I want to use the same inputField name more than once in the same page but the second data does not get saved although I am creating two different records. Suppose I have a custom object named Contract_Terms__c and I have a one to many relationship with another object called Term_Dates__c. So in my page I have two options - 'Enter Payment Date'  and 'Enter Cash Date', both with inputField name as term_dates.Term_Date__c. But the options creates two different records with differnt Term Type. If it is Payment Date it stores as 'Payment' and if it is 'Cash' it should store as 'cash' along with the date entered in the inputField. The record gets properly saved but the in the second record I am unable to save the date.

Here is the part of that code :
 <p>Payment Dates: <span style="padding:2px;"/> <apex:inputField id="term" 
<span style="padding:10px;"/><apex:CommandButton action="{!addTermDates}" value="Add">
</apex:CommandButton></p><br/> <p>Enter Cash Out Decision Date(s):<span style="padding:2px;"/> <apex:inputField id="term"
value="{!termDates.Date__c}"/> <span style="padding:5px;"/><apex:CommandButton action="{!addTermDatesCash}" value="Add">

 This is the same problem I am facing if I use the same field name once with apex:inputField and once with apex:outputField. This I need it in a scenario where depending on some condition once I need to make the field editable and once read-only.

Can anyone please suggest me how to go about this problem?


Ron HessRon Hess
i think you will need to different objects and then save the one that has the data you want

so your expressions would be




then in your controller you would have


which have different objects, so they can bind individualy

1. It is not recommended to have multiple inputfields bound to a single field. An alternate approach for your first problem would be to have a single inputfield with two buttons and in the respective action method determine the type of the record to be created. 


2. component ids should be unique. You can't have different components with the same id. Try using a single apex:inputText instead. You can disable it based on your logic.