hidden_field_tag
![Extensive documentation Importance_4](https://d2vfyqvduarcvs.cloudfront.net/images/importance_4.png?1349367920)
hidden_field_tag(name, value = nil, options = {})
public
Creates a hidden form input field used to transmit data that would be lost due to HTTP’s statelessness or data that should be hidden from the user.
Options
-
Creates standard HTML attributes for the tag.
Examples
hidden_field_tag 'tags_list' # => <input id="tags_list" name="tags_list" type="hidden" /> hidden_field_tag 'token', 'VUBJKB23UIVI1UU1VOBVI@' # => <input id="token" name="token" type="hidden" value="VUBJKB23UIVI1UU1VOBVI@" /> hidden_field_tag 'collected_input', '', onchange: "alert('Input collected!')" # => <input id="collected_input" name="collected_input" onchange="alert('Input collected!')" # type="hidden" value="" />
![Default_avatar_30](https://www.gravatar.com/avatar/7e4c1d95c11e907d2c5b4d7d6639dc40?size=30&default=http://apidock.com/images/default_avatar_30.png)
Storing array values
I tried to add a array value using hidden_field_tag and access it in jquery. It just returns the flattened version of array. eg:(If i try to store [1,[1,2,3]] in hidden_field_tag , in jquery iam just getting ‘1 1 2 3’) but if i use input field with type=hidden iam getting the correct value. Why is that?
![Default_avatar_30](https://www.gravatar.com/avatar/e2da7756e2fce664807547e1a312deac?size=30&default=http://apidock.com/images/default_avatar_30.png)
Rails 3.2.19
As Jebin reported, we are not getting the value in array format when we set the hidden_field_tag with an Array variable, instead it is a String that we are getting.