Module ActionView::Helpers::FormTagHelper
In: vendor/actionpack/lib/action_view/helpers/form_tag_helper.rb

Provides a number of methods for creating form tags that doesn’t rely on conventions with an object assigned to the template like FormHelper does. With the FormTagHelper, you provide the names and values yourself.

Methods

Public Instance methods

[Source]

    # File vendor/actionpack/lib/action_view/helpers/form_tag_helper.rb, line 63
63:       def check_box_tag(name, value = "1", checked = false, options = {})
64:         html_options = { "type" => "checkbox", "name" => name, "id" => name, "value" => value }.update(options.stringify_keys)
65:         html_options["checked"] = "checked" if checked
66:         tag("input", html_options)
67:       end

Outputs "</form>"

[Source]

    # File vendor/actionpack/lib/action_view/helpers/form_tag_helper.rb, line 29
29:       def end_form_tag
30:         "</form>"
31:       end

[Source]

    # File vendor/actionpack/lib/action_view/helpers/form_tag_helper.rb, line 45
45:       def file_field_tag(name, options = {})
46:         text_field_tag(name, nil, options.stringify_keys.update("type" => "file"))
47:       end

Starts a form tag that points the action to an url configured with url_for_options just like ActionController::Base#url_for. The method for the form defaults to POST.

Options:

  • :multipart - If set to true, the enctype is set to "multipart/form-data".

[Source]

    # File vendor/actionpack/lib/action_view/helpers/form_tag_helper.rb, line 14
14:       def form_tag(url_for_options = {}, options = {}, *parameters_for_url)
15:         html_options = { "method" => "post" }.merge(options.stringify_keys)
16: 
17:         if html_options[:multipart]
18:           html_options["enctype"] = "multipart/form-data"
19:           html_options.delete(:multipart)
20:         end
21: 
22:         html_options["action"] = url_for(url_for_options, *parameters_for_url)
23:         tag("form", html_options, true)
24:       end

[Source]

    # File vendor/actionpack/lib/action_view/helpers/form_tag_helper.rb, line 41
41:       def hidden_field_tag(name, value = nil, options = {})
42:         text_field_tag(name, value, options.stringify_keys.update("type" => "hidden"))
43:       end

[Source]

    # File vendor/actionpack/lib/action_view/helpers/form_tag_helper.rb, line 49
49:       def password_field_tag(name = "password", value = nil, options = {})
50:         text_field_tag(name, value, options.stringify_keys.update("type" => "password"))
51:       end

[Source]

    # File vendor/actionpack/lib/action_view/helpers/form_tag_helper.rb, line 69
69:       def radio_button_tag(name, value, checked = false, options = {})
70:         html_options = { "type" => "radio", "name" => name, "id" => name, "value" => value }.update(options.stringify_keys)
71:         html_options["checked"] = "checked" if checked
72:         tag("input", html_options)
73:       end

[Source]

    # File vendor/actionpack/lib/action_view/helpers/form_tag_helper.rb, line 33
33:       def select_tag(name, option_tags = nil, options = {})
34:         content_tag("select", option_tags, { "name" => name, "id" => name }.update(options.stringify_keys))
35:       end
start_form_tag(url_for_options = {}, options = {}, *parameters_for_url)

Alias for form_tag

[Source]

    # File vendor/actionpack/lib/action_view/helpers/form_tag_helper.rb, line 75
75:       def submit_tag(value = "Save changes", options = {})
76:         tag("input", { "type" => "submit", "name" => "submit", "value" => value }.update(options.stringify_keys))
77:       end

[Source]

    # File vendor/actionpack/lib/action_view/helpers/form_tag_helper.rb, line 53
53:       def text_area_tag(name, content = nil, options = {})
54:         options = options.stringify_keys
55:         if options["size"]
56:           options["cols"], options["rows"] = options["size"].split("x")
57:           options.delete("size")
58:         end
59: 
60:         content_tag("textarea", content, { "name" => name, "id" => name }.update(options.stringify_keys))
61:       end

[Source]

    # File vendor/actionpack/lib/action_view/helpers/form_tag_helper.rb, line 37
37:       def text_field_tag(name, value = nil, options = {})
38:         tag("input", { "type" => "text", "name" => name, "id" => name, "value" => value }.update(options.stringify_keys))
39:       end

[Validate]