Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

CGI::HtmlExtension#hidden

hidden(name = "", value = nil)

Generate a Hidden Input element as a string.

The attributes of the element can be specified as two arguments, name and value.

Alternatively, the attributes can be specified as a hash.

Example
hidden("name")
  # <INPUT TYPE="hidden" NAME="name">

hidden("name", "value")
  # <INPUT TYPE="hidden" NAME="name" VALUE="value">

hidden("NAME" => "name", "VALUE" => "reset", "ID" => "foo")
  # <INPUT TYPE="hidden" NAME="name" VALUE="value" ID="foo">
See also #form #html #file_field #image_button also in 3.3 · 3.2 · 3.1 · 3.0