Method: ActionView::Helpers::FormTagHelper#hidden_field_tag

Defined in:
actionview/lib/action_view/helpers/form_tag_helper.rb

#hidden_field_tag(name, value = nil, options = {}) ⇒ Object

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 type="hidden" name="tags_list" id="tags_list" autocomplete="off" />

hidden_field_tag 'token', 'VUBJKB23UIVI1UU1VOBVI@'
# => <input type="hidden" name="token" id="token" value="VUBJKB23UIVI1UU1VOBVI@" autocomplete="off" />

hidden_field_tag 'collected_input', '', onchange: "alert('Input collected!')"
# => <input type="hidden" name="collected_input" id="collected_input"
     value="" onchange="alert(&#39;Input collected!&#39;)" autocomplete="off" />


308
309
310
# File 'actionview/lib/action_view/helpers/form_tag_helper.rb', line 308

def hidden_field_tag(name, value = nil, options = {})
  text_field_tag(name, value, options.merge(type: :hidden, autocomplete: "off"))
end