I want to build page with dynamic input type. I want vf code to look like this:
<apex:repeat value="{!myData}" var="myEntry">
<apex:pageBlockSection>
<apex:pageBlockSectionItem>
<apex:outputText value="{!myEntry.label}"/>
<apex:input value="{!myEntry.value}" type="{!myEntry.type}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:repeat>
For this I have apex code like this:
public class MyEntry {
public MyEntry(String label, String key, String value, String type) {
this.label = label;
this.key = key;
this.value = value;
this.type = type;
}
public String label { get; set; }
public String key { get; set; }
public String value { get; set; }
public String type { get; set; }
}
public List<MyEntry> MyData {
get {
if (MyData == null) {
MyData = new List<MyEntry>();
MyData.add(new MyEntry('Some date', 'Some_Date__c', null, 'date'));
MyData.add(new MyEntry('Some checkbox', 'Some_Checkbox__c', null, 'checkbox'));
MyData.add(new MyEntry('Some text', 'Some_Text__c', null, 'text'));
}
return MyData;
}
set;
}
But when I use type="{!myEntry.type}"
I get error:
Error:(1, 1) Literal value is required for attribute id in <apex:input>
And for html-type="{!myEntry.type}"
I get this:
Error:(1, 1) Cannot override attribute 'type' on component <apex:input>
Is there any solution for my problem?