module CGI::HtmlExtension
def form(method = "post", action = script_name, enctype = "application/x-www-form-urlencoded")
form("METHOD" => "post", "ENCTYPE" => "enctype") { "string" }
#
form("get", "url") { "string" }
#
form("get") { "string" }
#
form{ "string" }
See also #multipart_form() for forms that include file uploads.
Alternatively, the attributes can be specified as a hash.
defaults to "application/x-www-form-urlencoded".
+action+ defaults to the current CGI script name. +enctype+
+method+ should be either "get" or "post", and defaults to the latter.
Generate a Form element as a string.
def form(method = "post", action = script_name, enctype = "application/x-www-form-urlencoded") attributes = if method.kind_of?(String) { "METHOD" => method, "ACTION" => action, "ENCTYPE" => enctype } else unless method.has_key?("METHOD") method["METHOD"] = "post" end unless method.has_key?("ENCTYPE") method["ENCTYPE"] = enctype end method end if block_given? body = yield else body = "" end if @output_hidden body << @output_hidden.collect{|k,v| "<INPUT TYPE=\"HIDDEN\" NAME=\"#{k}\" VALUE=\"#{v}\">" }.join end super(attributes){body} end