Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
CGI::HtmlExtension#hidden
hidden(name = "", value = nil)
lib/cgi/html.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/cgi/html.rb, line 351
def hidden(name = "", value = nil)
attributes = if name.kind_of?(String)
{ "TYPE" => "hidden", "NAME" => name, "VALUE" => value }
else
name["TYPE"] = "hidden"
name
end
input(attributes)
end
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">