Method: ActionView::Helpers::FormBuilder#hidden_field

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

#hidden_field(method, options = {}) ⇒ Object

Returns a hidden input tag tailored for accessing a specified attribute (identified by method) on an object assigned to the template (identified by object). Additional options on the input tag can be passed as a hash with options. These options will be tagged onto the HTML as an HTML element attribute as in the example shown.

Examples

# Let's say that @signup.pass_confirm returns true:
hidden_field(:pass_confirm)
# => <input type="hidden" id="signup_pass_confirm" name="signup[pass_confirm]" value="true" />

# Let's say that @article.tag_list returns "blog, ruby":
hidden_field(:tag_list)
# => <input type="hidden" id="article_tag_list" name="article[tag_list]" value="blog, ruby" />

# Let's say that @user.token returns "abcde":
hidden_field(:token)
# => <input type="hidden" id="user_token" name="user[token]" value="abcde" />


2518
2519
2520
2521
# File 'actionview/lib/action_view/helpers/form_helper.rb', line 2518

def hidden_field(method, options = {})
  @emitted_hidden_id = true if method == :id
  @template.hidden_field(@object_name, method, objectify_options(options))
end