+ Start a Discussion

Dynamic input fields

I've a requirement to display input fields of a particular standard object on my VF page; but the catch is, the set of fields I need displayed is going to be customizable (field names stored in a custom object, for example). How can I dynamically display these input fields based on the selections the user has made?
Thanks in advance.

Message Edited by santosh on 06-10-2008 02:46 AM
"the set of fields I need displayed is going to be customizable (field names stored in a custom object, for example)" - can you explain this a bit more? Do you plan to leverage salesforce custom fields and then add your own layer on top of them that would allow a subset of field names on an sobject to be saved?

The hard part, which may be insurmountable at the current time (we do a feature on the roadmap that will make this a snap but it is going to be awhile before it makes it out to you), is going to be the lack of support for dynamic creation of value bindings and components.
Thanks for your response...
Here's is what I want; The set of fields to be displayed on this page is going to be different for each ORG, the admin is going to set that using a custom object where I'll have a record storing the CSVs of the field names the admin wants to display for his ORG, the VF page (through a controller) will be reading this record and rendering only those fields on the page!
Hope that helps.
Thanks in advance.
You could probably use the rendered attribute on the inputField tags. In your page have all the fields listed and in your controller have a map or list boolean with each entry initialized to false so that by default no inputFields get rendered then when you parse the cvs file set the ones you want displayed to true. Not ideal but it could work.

Message Edited by Scott.M on 06-10-2008 08:36 AM

Message Edited by Scott.M on 06-10-2008 08:37 AM
Thank you very much, Scott

This is exactly what I too was contemplating!      
That will not allow you to support your customers adding custom fields - if you are only talking about a finite set of custom fields that you define for yourself the brute force approach will work fine (will require occasional maintenance when/if you add more custom fields). It sounded like you were talking about something a bit more sophisticated.
As a matter of fact, newer fields have to be accomodated on the fly...I will not be working with a finite set of fields in all probability, any thoughts on that?
Alternatively, is there a way I can display all fields of the object in edit mode (input fields) just like an <apex:detail /> tag displays all fields in the detail mode?

Much appreciated.
I have an extra layer of complexity for dynamic input field...

Can I have <apex:inputText> fields within a pageblocktable and assign the "id" of those inputtext fields to a {!blah.value} merge field??

so I can have an extra input text field for every record with an id that is related in someway to that record which I can reference using some javascript or similar.

for example....

    <apex:PageBlockTable value="{!items}" var="it">
      <apex:column headerValue="Product" value="{!it.Product__c}" />
      <apex:column headerValue="Price" value="{!it.Line_Total_inc_GST__c}" />
      <apex:column headerValue="Amount Paid" value="{!it.Amount_Paid__c}" />
      <apex:column headerValue="Amount to Apply">
        <apex:inputText id="{!it.Id}" />

I've tried and I get a compile error but maybe you guys know a work around.