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
santoshsantosh 

Dynamic input fields

Hello,
 
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
dchasmandchasman
"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.
santoshsantosh
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.
Scott.MScott.M
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
santoshsantosh
Thank you very much, Scott

This is exactly what I too was contemplating!      
dchasmandchasman
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.
santoshsantosh
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?
 
-Thanks
santoshsantosh
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.
patskepatske
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....

Code:
    <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}" />
      </apex:column>
    </apex:PageBlockTable> 

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