For one of the requirements I'm building a visualforce page with a controller. The problem is that I can not save the page with <apex:input>
type being number. Compilation error is:
Expected input type 'text', got 'number' for Id data type
It is filled by the value(not the key) of a map in my controller.
Controller code(stripped down to wrapper only and used lines):
public MyWrapperClass wrapper {get; set;}
// More properties
// Constructor, other methods
public class MyWrapperClass {
public Map<String, Integer> myMap { get; set; }
// More properties
public MyWrapperClass(Custom_object__c custObj, List<Custom_object_Child__c> cocs) {
myMap = new Map<String, Integer>();
for (Custom_object_Child__c coc : cocs) {
myMap.put(coc.Unique_Name__c, Integer.valueOf(coc.Number_field__c));
}
}
}
VF page:
<apex:repeat var="coc" value="{!wrapper.myMap}">
<apex:input type="number" value="{!wrapper.myMap[coc]}" />
</apex:repeat>
Is there a workaround to this? I know I can add javascript check on the field to only allow numbers, but I'd like to try to keep javascript to a minimum.
P.S. Please note, that if I change the type="number"
to type="text"
, then the page saves without any problem.