+ Start a Discussion
ministe_2003ministe_2003 

Map values in the new HTML 5 apex:input field

I'm having trouble using the new html5 compliant apex:input field.  I'm working with maps and trying to set a number in the value part of the map, related to a corresponding Id key.  The map is called "prodQty" and an entry in the map might look like {XXXXXXXXXXXXXXXXXX,10} so the Key is an Id and the value is a number.

 

Here is a sample of what works using a normal input:text field:

 

<apex:inputText value="{!prodQty[p.Id]}" />

 All this does on the VF page is simply create an inputText field and display the corresponding number from the map.  I can change that number and it updates the map no problem.

 

I wanted to use the HTML5 number type and so set it up with this code:

 

<apex:input type="number" value="{!prodQty[p.Id]}" />

 Looks pretty standard to me, but I get this error:

 

Expected input type 'text', got 'number' for Id data type

 

It seems to be pulling through the key of the map rather than the value which is odd, because with a standard inputText component the value syntax works perfectly so why does the new component not recognise that I'm pulling through a number instead of an Id?  Is it impossible to use this new component with a map value?  It'll be an unfortunate limitation if that's the case!

 

Thanks for any advice.

ministe_2003ministe_2003

One more thing, I've tried to set the value attribute with a variable, hoping that the variable would do the work in pulling back the map's value (a number) and then the input would just display it:

 

<apex:variable var="qty" value="{!prodQty[p.Id]}" />
<apex:input type="number" value="{!qty}" />

 but then I get:

 

Input type 'number' does not support ANY data type.  Try settng type to 'text'

Mishael LegaspiMishael Legaspi
Hi! Were you able to solve this problem? I'm having a similar problem. Apparently, the type="number" would work if you're using a List, not a Map. It's a bit frustrating that I can't make it work with Maps :(
ministe_2003ministe_2003
Afraid not, ended up sticking to a standard input text.  My aim at the time was to be able to use a number spinner that would also work on mobile devices, but I ended up using jQuery for it instead
Mishael LegaspiMishael Legaspi
Oh okay. Thanks for the update! :)