You need to sign in to do that
Don't have an account?

How do I use the same input field name more than once in a page?
Hi,
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 :
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?
Regards,
Jina
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 :
Code:
<p>Payment Dates: <span style="padding:2px;"/> <apex:inputField id="term"
value="{!termDates.Date__c}"/>
<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">
</apex:CommandButton></p>
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?
Regards,
Jina
so your expressions would be
then in your controller you would have
getTermDates()
and
getTermDates2()
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.