I'm new to salesforce development and I'm trying to dynamically create fields based on the field name selected. I'm not sure how to achieve this.
I have a picklist of fieldnames for a Lead object in a visualforce page. When a fieldname is selected, I want to re-render the fieldvalue type based on the fieldname selected. For eg.
If selected fieldName is 'Lead.Rating', I want to display a picklist whereas if the selected fieldname is 'Lead.FirstName' I want to display a textbox.
I have read about dynamic component and dynamic bindings but I'm not sure which to use in my context. Any help would be appreciated
Edit:
VF code snippet:
<apex:column headerValue="Field" style="width:50px">
<apex:actionRegion >
<apex:selectList style="width:160px" value="{!filter.Record_Field__c}" size="1">
<apex:selectOptions value="{!LeadFields}"/>
<apex:actionSupport event="onchange" reRender="fieldpanel"/>
</apex:selectList>
</apex:actionRegion>
</apex:column>
<apex:column headerValue="Value">
<apex:outputPanel id="fieldpanel">
<apex:inputField style="width:150px" value="{!filter.Record_Value__c}" id="ffield" rendered="true" />
<apex:actionRegion>
<apex:inputField style="width:150px" id="value1" value="{!selectedObj[filter.Record_Field__c]}"
rendered="{!IF(filter.Record_Field__c != null , true , false)}">
</apex:inputField>
</apex:actionRegion>
</apex:outputPanel>
Here selectedObj is a 'Lead' sObject.
This works well for rendering the correct input type. however I want to assign the value obtained from {!selectedObj[filter.Record_Field__c]} to filter.Record_Value__c. How can I do that?