inputEx - HiddenField Usage

Basic HiddenField creation

The hidden field is by definition 'invisible', so there isn't a lot to see. However, it can be useful to keep an id :

1var exampleDiv = YAHOO.util.Dom.get('container1'); 
2var group = new inputEx.Group({ 
3        fields: [  
4            { type: 'hidden', name: 'id', value: 12 }, 
5            { type: 'hidden', name: 'lastname', value: 'Scott' }, 
6            { type: 'string', name: 'firstname', label: 'Firstname', required: true, value:'James'
7        ],  
8        parentEl: exampleDiv 
9}); 
10var button=inputEx.cn('button',null,null'Get Value');  
11exampleDiv.appendChild(button);  
12YAHOO.util.Event.addListener(button, 'click'function(){ alert(YAHOO.lang.JSON.stringify(group.getValue()) ); }); 
view plain | print | ?

Note that <hiddenFieldInstance>.getValue() returns the value as stored, without type casting (we store an integer -> we get an integer).

However, when the form is submitted via a 'submit' button, the hidden value is sent as 'string' whatever its datatype was... (we store 12, we submit "12").

This is a limitation of the classic HTML form submit. To circumvent the problem, use an ajax submit of the form (which relies on getValue) : see form examples.