actionpack 3.2.22.5 → 4.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +641 -418
- data/MIT-LICENSE +1 -1
- data/README.rdoc +5 -288
- data/lib/abstract_controller.rb +1 -8
- data/lib/abstract_controller/asset_paths.rb +2 -2
- data/lib/abstract_controller/base.rb +39 -37
- data/lib/abstract_controller/callbacks.rb +101 -82
- data/lib/abstract_controller/collector.rb +7 -3
- data/lib/abstract_controller/helpers.rb +23 -11
- data/lib/abstract_controller/layouts.rb +68 -73
- data/lib/abstract_controller/logger.rb +1 -2
- data/lib/abstract_controller/rendering.rb +22 -13
- data/lib/abstract_controller/translation.rb +16 -1
- data/lib/abstract_controller/url_for.rb +6 -6
- data/lib/abstract_controller/view_paths.rb +1 -1
- data/lib/action_controller.rb +15 -6
- data/lib/action_controller/base.rb +46 -22
- data/lib/action_controller/caching.rb +46 -33
- data/lib/action_controller/caching/fragments.rb +23 -53
- data/lib/action_controller/deprecated.rb +5 -1
- data/lib/action_controller/deprecated/integration_test.rb +3 -0
- data/lib/action_controller/log_subscriber.rb +11 -8
- data/lib/action_controller/metal.rb +16 -30
- data/lib/action_controller/metal/conditional_get.rb +76 -32
- data/lib/action_controller/metal/data_streaming.rb +20 -26
- data/lib/action_controller/metal/exceptions.rb +19 -6
- data/lib/action_controller/metal/flash.rb +24 -9
- data/lib/action_controller/metal/force_ssl.rb +32 -9
- data/lib/action_controller/metal/head.rb +25 -4
- data/lib/action_controller/metal/helpers.rb +6 -9
- data/lib/action_controller/metal/hide_actions.rb +1 -2
- data/lib/action_controller/metal/http_authentication.rb +105 -87
- data/lib/action_controller/metal/implicit_render.rb +1 -1
- data/lib/action_controller/metal/instrumentation.rb +2 -1
- data/lib/action_controller/metal/live.rb +141 -0
- data/lib/action_controller/metal/mime_responds.rb +161 -47
- data/lib/action_controller/metal/params_wrapper.rb +112 -74
- data/lib/action_controller/metal/rack_delegation.rb +9 -3
- data/lib/action_controller/metal/redirecting.rb +15 -20
- data/lib/action_controller/metal/renderers.rb +11 -9
- data/lib/action_controller/metal/rendering.rb +8 -0
- data/lib/action_controller/metal/request_forgery_protection.rb +112 -19
- data/lib/action_controller/metal/responder.rb +20 -19
- data/lib/action_controller/metal/streaming.rb +12 -18
- data/lib/action_controller/metal/strong_parameters.rb +516 -0
- data/lib/action_controller/metal/testing.rb +13 -18
- data/lib/action_controller/metal/url_for.rb +27 -25
- data/lib/action_controller/model_naming.rb +12 -0
- data/lib/action_controller/railtie.rb +33 -17
- data/lib/action_controller/railties/helpers.rb +22 -0
- data/lib/action_controller/record_identifier.rb +18 -72
- data/lib/action_controller/test_case.rb +215 -123
- data/lib/action_controller/vendor/html-scanner.rb +4 -19
- data/lib/action_dispatch.rb +27 -19
- data/lib/action_dispatch/http/cache.rb +63 -11
- data/lib/action_dispatch/http/filter_parameters.rb +18 -8
- data/lib/action_dispatch/http/filter_redirect.rb +37 -0
- data/lib/action_dispatch/http/headers.rb +27 -19
- data/lib/action_dispatch/http/mime_negotiation.rb +25 -2
- data/lib/action_dispatch/http/mime_type.rb +145 -113
- data/lib/action_dispatch/http/mime_types.rb +1 -1
- data/lib/action_dispatch/http/parameter_filter.rb +44 -46
- data/lib/action_dispatch/http/parameters.rb +12 -5
- data/lib/action_dispatch/http/rack_cache.rb +2 -3
- data/lib/action_dispatch/http/request.rb +49 -18
- data/lib/action_dispatch/http/response.rb +129 -35
- data/lib/action_dispatch/http/upload.rb +60 -17
- data/lib/action_dispatch/http/url.rb +53 -31
- data/lib/action_dispatch/journey.rb +5 -0
- data/lib/action_dispatch/journey/backwards.rb +5 -0
- data/lib/action_dispatch/journey/formatter.rb +146 -0
- data/lib/action_dispatch/journey/gtg/builder.rb +162 -0
- data/lib/action_dispatch/journey/gtg/simulator.rb +44 -0
- data/lib/action_dispatch/journey/gtg/transition_table.rb +156 -0
- data/lib/action_dispatch/journey/nfa/builder.rb +76 -0
- data/lib/action_dispatch/journey/nfa/dot.rb +36 -0
- data/lib/action_dispatch/journey/nfa/simulator.rb +47 -0
- data/lib/action_dispatch/journey/nfa/transition_table.rb +163 -0
- data/lib/action_dispatch/journey/nodes/node.rb +124 -0
- data/lib/action_dispatch/journey/parser.rb +206 -0
- data/lib/action_dispatch/journey/parser.y +47 -0
- data/lib/action_dispatch/journey/parser_extras.rb +23 -0
- data/lib/action_dispatch/journey/path/pattern.rb +196 -0
- data/lib/action_dispatch/journey/route.rb +116 -0
- data/lib/action_dispatch/journey/router.rb +164 -0
- data/lib/action_dispatch/journey/router/strexp.rb +24 -0
- data/lib/action_dispatch/journey/router/utils.rb +54 -0
- data/lib/action_dispatch/journey/routes.rb +75 -0
- data/lib/action_dispatch/journey/scanner.rb +61 -0
- data/lib/action_dispatch/journey/visitors.rb +189 -0
- data/lib/action_dispatch/journey/visualizer/fsm.css +34 -0
- data/lib/action_dispatch/journey/visualizer/fsm.js +134 -0
- data/lib/action_dispatch/journey/visualizer/index.html.erb +52 -0
- data/lib/action_dispatch/middleware/callbacks.rb +9 -4
- data/lib/action_dispatch/middleware/cookies.rb +168 -57
- data/lib/action_dispatch/middleware/debug_exceptions.rb +26 -17
- data/lib/action_dispatch/middleware/exception_wrapper.rb +27 -3
- data/lib/action_dispatch/middleware/flash.rb +58 -58
- data/lib/action_dispatch/middleware/params_parser.rb +14 -29
- data/lib/action_dispatch/middleware/public_exceptions.rb +31 -14
- data/lib/action_dispatch/middleware/reloader.rb +6 -6
- data/lib/action_dispatch/middleware/remote_ip.rb +145 -39
- data/lib/action_dispatch/middleware/request_id.rb +2 -6
- data/lib/action_dispatch/middleware/session/abstract_store.rb +22 -20
- data/lib/action_dispatch/middleware/session/cache_store.rb +3 -3
- data/lib/action_dispatch/middleware/session/cookie_store.rb +81 -7
- data/lib/action_dispatch/middleware/session/mem_cache_store.rb +8 -3
- data/lib/action_dispatch/middleware/show_exceptions.rb +12 -45
- data/lib/action_dispatch/middleware/ssl.rb +70 -0
- data/lib/action_dispatch/middleware/stack.rb +6 -1
- data/lib/action_dispatch/middleware/static.rb +5 -24
- data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb +14 -11
- data/lib/action_dispatch/middleware/templates/rescues/_source.erb +25 -0
- data/lib/action_dispatch/middleware/templates/rescues/_trace.erb +3 -3
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb +15 -9
- data/lib/action_dispatch/middleware/templates/rescues/layout.erb +121 -5
- data/lib/action_dispatch/middleware/templates/rescues/missing_template.erb +7 -2
- data/lib/action_dispatch/middleware/templates/rescues/routing_error.erb +30 -15
- data/lib/action_dispatch/middleware/templates/rescues/template_error.erb +39 -13
- data/lib/action_dispatch/middleware/templates/rescues/unknown_action.erb +6 -2
- data/lib/action_dispatch/middleware/templates/routes/_route.html.erb +16 -0
- data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +144 -0
- data/lib/action_dispatch/railtie.rb +16 -6
- data/lib/action_dispatch/request/session.rb +181 -0
- data/lib/action_dispatch/routing.rb +41 -40
- data/lib/action_dispatch/routing/inspector.rb +240 -0
- data/lib/action_dispatch/routing/mapper.rb +501 -273
- data/lib/action_dispatch/routing/polymorphic_routes.rb +16 -20
- data/lib/action_dispatch/routing/redirection.rb +46 -29
- data/lib/action_dispatch/routing/route_set.rb +203 -164
- data/lib/action_dispatch/routing/routes_proxy.rb +2 -0
- data/lib/action_dispatch/routing/url_for.rb +48 -33
- data/lib/action_dispatch/testing/assertions/dom.rb +3 -13
- data/lib/action_dispatch/testing/assertions/response.rb +32 -40
- data/lib/action_dispatch/testing/assertions/routing.rb +40 -39
- data/lib/action_dispatch/testing/assertions/selector.rb +15 -20
- data/lib/action_dispatch/testing/assertions/tag.rb +20 -23
- data/lib/action_dispatch/testing/integration.rb +41 -22
- data/lib/action_dispatch/testing/test_process.rb +9 -6
- data/lib/action_dispatch/testing/test_request.rb +7 -3
- data/lib/action_pack.rb +1 -1
- data/lib/action_pack/version.rb +4 -4
- data/lib/action_view.rb +17 -8
- data/lib/action_view/base.rb +15 -34
- data/lib/action_view/buffers.rb +1 -1
- data/lib/action_view/context.rb +4 -4
- data/lib/action_view/dependency_tracker.rb +91 -0
- data/lib/action_view/digestor.rb +85 -0
- data/lib/action_view/flows.rb +1 -4
- data/lib/action_view/helpers.rb +2 -4
- data/lib/action_view/helpers/active_model_helper.rb +3 -4
- data/lib/action_view/helpers/asset_tag_helper.rb +211 -353
- data/lib/action_view/helpers/asset_url_helper.rb +354 -0
- data/lib/action_view/helpers/atom_feed_helper.rb +13 -10
- data/lib/action_view/helpers/cache_helper.rb +150 -18
- data/lib/action_view/helpers/capture_helper.rb +42 -29
- data/lib/action_view/helpers/csrf_helper.rb +0 -2
- data/lib/action_view/helpers/date_helper.rb +268 -247
- data/lib/action_view/helpers/debug_helper.rb +10 -11
- data/lib/action_view/helpers/form_helper.rb +904 -547
- data/lib/action_view/helpers/form_options_helper.rb +341 -166
- data/lib/action_view/helpers/form_tag_helper.rb +188 -88
- data/lib/action_view/helpers/javascript_helper.rb +23 -16
- data/lib/action_view/helpers/number_helper.rb +148 -354
- data/lib/action_view/helpers/output_safety_helper.rb +3 -3
- data/lib/action_view/helpers/record_tag_helper.rb +17 -22
- data/lib/action_view/helpers/rendering_helper.rb +2 -4
- data/lib/action_view/helpers/sanitize_helper.rb +3 -6
- data/lib/action_view/helpers/tag_helper.rb +43 -37
- data/lib/action_view/helpers/tags.rb +39 -0
- data/lib/action_view/helpers/tags/base.rb +148 -0
- data/lib/action_view/helpers/tags/check_box.rb +64 -0
- data/lib/action_view/helpers/tags/checkable.rb +16 -0
- data/lib/action_view/helpers/tags/collection_check_boxes.rb +43 -0
- data/lib/action_view/helpers/tags/collection_helpers.rb +83 -0
- data/lib/action_view/helpers/tags/collection_radio_buttons.rb +36 -0
- data/lib/action_view/helpers/tags/collection_select.rb +28 -0
- data/lib/action_view/helpers/tags/color_field.rb +25 -0
- data/lib/action_view/helpers/tags/date_field.rb +13 -0
- data/lib/action_view/helpers/tags/date_select.rb +72 -0
- data/lib/action_view/helpers/tags/datetime_field.rb +22 -0
- data/lib/action_view/helpers/tags/datetime_local_field.rb +19 -0
- data/lib/action_view/helpers/tags/datetime_select.rb +8 -0
- data/lib/action_view/helpers/tags/email_field.rb +8 -0
- data/lib/action_view/helpers/tags/file_field.rb +8 -0
- data/lib/action_view/helpers/tags/grouped_collection_select.rb +29 -0
- data/lib/action_view/helpers/tags/hidden_field.rb +8 -0
- data/lib/action_view/helpers/tags/label.rb +65 -0
- data/lib/action_view/helpers/tags/month_field.rb +13 -0
- data/lib/action_view/helpers/tags/number_field.rb +18 -0
- data/lib/action_view/helpers/tags/password_field.rb +12 -0
- data/lib/action_view/helpers/tags/radio_button.rb +31 -0
- data/lib/action_view/helpers/tags/range_field.rb +8 -0
- data/lib/action_view/helpers/tags/search_field.rb +24 -0
- data/lib/action_view/helpers/tags/select.rb +41 -0
- data/lib/action_view/helpers/tags/tel_field.rb +8 -0
- data/lib/action_view/helpers/tags/text_area.rb +18 -0
- data/lib/action_view/helpers/tags/text_field.rb +29 -0
- data/lib/action_view/helpers/tags/time_field.rb +13 -0
- data/lib/action_view/helpers/tags/time_select.rb +8 -0
- data/lib/action_view/helpers/tags/time_zone_select.rb +20 -0
- data/lib/action_view/helpers/tags/url_field.rb +8 -0
- data/lib/action_view/helpers/tags/week_field.rb +13 -0
- data/lib/action_view/helpers/text_helper.rb +126 -113
- data/lib/action_view/helpers/translation_helper.rb +32 -16
- data/lib/action_view/helpers/url_helper.rb +200 -271
- data/lib/action_view/locale/en.yml +1 -105
- data/lib/action_view/log_subscriber.rb +6 -4
- data/lib/action_view/lookup_context.rb +15 -39
- data/lib/action_view/model_naming.rb +12 -0
- data/lib/action_view/path_set.rb +9 -39
- data/lib/action_view/railtie.rb +6 -22
- data/lib/action_view/record_identifier.rb +84 -0
- data/lib/action_view/renderer/abstract_renderer.rb +10 -19
- data/lib/action_view/renderer/partial_renderer.rb +144 -81
- data/lib/action_view/renderer/renderer.rb +2 -19
- data/lib/action_view/renderer/streaming_template_renderer.rb +2 -5
- data/lib/action_view/renderer/template_renderer.rb +14 -13
- data/lib/action_view/routing_url_for.rb +107 -0
- data/lib/action_view/template.rb +22 -21
- data/lib/action_view/template/error.rb +22 -12
- data/lib/action_view/template/handlers.rb +12 -9
- data/lib/action_view/template/handlers/builder.rb +1 -1
- data/lib/action_view/template/handlers/erb.rb +11 -16
- data/lib/action_view/template/handlers/raw.rb +11 -0
- data/lib/action_view/template/resolver.rb +111 -83
- data/lib/action_view/template/text.rb +12 -8
- data/lib/action_view/template/types.rb +57 -0
- data/lib/action_view/test_case.rb +66 -43
- data/lib/action_view/testing/resolvers.rb +3 -2
- data/lib/action_view/vendor/html-scanner.rb +20 -0
- data/lib/{action_controller → action_view}/vendor/html-scanner/html/document.rb +0 -0
- data/lib/{action_controller → action_view}/vendor/html-scanner/html/node.rb +12 -12
- data/lib/{action_controller → action_view}/vendor/html-scanner/html/sanitizer.rb +18 -7
- data/lib/{action_controller → action_view}/vendor/html-scanner/html/selector.rb +1 -1
- data/lib/{action_controller → action_view}/vendor/html-scanner/html/tokenizer.rb +1 -1
- data/lib/{action_controller → action_view}/vendor/html-scanner/html/version.rb +0 -0
- metadata +135 -125
- data/lib/action_controller/caching/actions.rb +0 -185
- data/lib/action_controller/caching/pages.rb +0 -187
- data/lib/action_controller/caching/sweeping.rb +0 -97
- data/lib/action_controller/deprecated/performance_test.rb +0 -1
- data/lib/action_controller/metal/compatibility.rb +0 -65
- data/lib/action_controller/metal/session_management.rb +0 -14
- data/lib/action_controller/railties/paths.rb +0 -25
- data/lib/action_dispatch/middleware/best_standards_support.rb +0 -30
- data/lib/action_dispatch/middleware/body_proxy.rb +0 -30
- data/lib/action_dispatch/middleware/head.rb +0 -18
- data/lib/action_dispatch/middleware/rescue.rb +0 -26
- data/lib/action_dispatch/testing/performance_test.rb +0 -10
- data/lib/action_view/asset_paths.rb +0 -142
- data/lib/action_view/helpers/asset_paths.rb +0 -7
- data/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb +0 -146
- data/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb +0 -93
- data/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb +0 -193
- data/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb +0 -148
- data/lib/sprockets/assets.rake +0 -99
- data/lib/sprockets/bootstrap.rb +0 -37
- data/lib/sprockets/compressors.rb +0 -83
- data/lib/sprockets/helpers.rb +0 -6
- data/lib/sprockets/helpers/isolated_helper.rb +0 -13
- data/lib/sprockets/helpers/rails_helper.rb +0 -182
- data/lib/sprockets/railtie.rb +0 -62
- data/lib/sprockets/static_compiler.rb +0 -56
@@ -1,17 +1,16 @@
|
|
1
1
|
require 'cgi'
|
2
2
|
require 'action_view/helpers/tag_helper'
|
3
|
-
require 'active_support/core_ext/object/blank'
|
4
3
|
require 'active_support/core_ext/string/output_safety'
|
5
4
|
require 'active_support/core_ext/module/attribute_accessors'
|
6
5
|
|
7
6
|
module ActionView
|
8
7
|
# = Action View Form Tag Helpers
|
9
8
|
module Helpers
|
10
|
-
# Provides a number of methods for creating form tags that
|
9
|
+
# Provides a number of methods for creating form tags that don't rely on an Active Record object assigned to the template like
|
11
10
|
# FormHelper does. Instead, you provide the names and values manually.
|
12
11
|
#
|
13
12
|
# NOTE: The HTML options <tt>disabled</tt>, <tt>readonly</tt>, and <tt>multiple</tt> can all be treated as booleans. So specifying
|
14
|
-
# <tt
|
13
|
+
# <tt>disabled: true</tt> will give <tt>disabled="disabled"</tt>.
|
15
14
|
module FormTagHelper
|
16
15
|
extend ActiveSupport::Concern
|
17
16
|
|
@@ -19,7 +18,7 @@ module ActionView
|
|
19
18
|
include TextHelper
|
20
19
|
|
21
20
|
mattr_accessor :embed_authenticity_token_in_remote_forms
|
22
|
-
self.embed_authenticity_token_in_remote_forms =
|
21
|
+
self.embed_authenticity_token_in_remote_forms = false
|
23
22
|
|
24
23
|
# Starts a form tag that points the action to an url configured with <tt>url_for_options</tt> just like
|
25
24
|
# ActionController::Base#url_for. The method for the form defaults to POST.
|
@@ -27,14 +26,14 @@ module ActionView
|
|
27
26
|
# ==== Options
|
28
27
|
# * <tt>:multipart</tt> - If set to true, the enctype is set to "multipart/form-data".
|
29
28
|
# * <tt>:method</tt> - The method to use when submitting the form, usually either "get" or "post".
|
30
|
-
# If "put", "delete", or another verb is used, a hidden input with name <tt>_method</tt>
|
29
|
+
# If "patch", "put", "delete", or another verb is used, a hidden input with name <tt>_method</tt>
|
31
30
|
# is added to simulate the verb over post.
|
32
31
|
# * <tt>:authenticity_token</tt> - Authenticity token to use in the form. Use only if you need to
|
33
32
|
# pass custom authenticity token string, or to not add authenticity_token field at all
|
34
33
|
# (by passing <tt>false</tt>). Remote forms may omit the embedded authenticity token
|
35
34
|
# by setting <tt>config.action_view.embed_authenticity_token_in_remote_forms = false</tt>.
|
36
35
|
# This is helpful when you're fragment-caching the form. Remote forms get the
|
37
|
-
# authenticity from the <tt>meta</tt> tag, so embedding is unnecessary unless you
|
36
|
+
# authenticity token from the <tt>meta</tt> tag, so embedding is unnecessary unless you
|
38
37
|
# support browsers without JavaScript.
|
39
38
|
# * A list of parameters to feed to the URL the form will be posted to.
|
40
39
|
# * <tt>:remote</tt> - If set to true, will allow the Unobtrusive JavaScript drivers to control the
|
@@ -44,10 +43,10 @@ module ActionView
|
|
44
43
|
# form_tag('/posts')
|
45
44
|
# # => <form action="/posts" method="post">
|
46
45
|
#
|
47
|
-
# form_tag('/posts/1', :
|
46
|
+
# form_tag('/posts/1', method: :put)
|
48
47
|
# # => <form action="/posts/1" method="post"> ... <input name="_method" type="hidden" value="put" /> ...
|
49
48
|
#
|
50
|
-
# form_tag('/upload', :
|
49
|
+
# form_tag('/upload', multipart: true)
|
51
50
|
# # => <form action="/upload" method="post" enctype="multipart/form-data">
|
52
51
|
#
|
53
52
|
# <%= form_tag('/posts') do -%>
|
@@ -55,13 +54,13 @@ module ActionView
|
|
55
54
|
# <% end -%>
|
56
55
|
# # => <form action="/posts" method="post"><div><input type="submit" name="commit" value="Save" /></div></form>
|
57
56
|
#
|
58
|
-
# <%= form_tag('/posts', :
|
57
|
+
# <%= form_tag('/posts', remote: true) %>
|
59
58
|
# # => <form action="/posts" method="post" data-remote="true">
|
60
59
|
#
|
61
|
-
# form_tag('http://far.away.com/form', :
|
60
|
+
# form_tag('http://far.away.com/form', authenticity_token: false)
|
62
61
|
# # form without authenticity token
|
63
62
|
#
|
64
|
-
# form_tag('http://far.away.com/form', :
|
63
|
+
# form_tag('http://far.away.com/form', authenticity_token: "cf50faa3fe97702ca1ae")
|
65
64
|
# # form with custom authenticity token
|
66
65
|
#
|
67
66
|
def form_tag(url_for_options = {}, options = {}, &block)
|
@@ -97,27 +96,31 @@ module ActionView
|
|
97
96
|
# # => <select id="count" name="count"><option>1</option><option>2</option>
|
98
97
|
# # <option>3</option><option>4</option></select>
|
99
98
|
#
|
100
|
-
# select_tag "colors", "<option>Red</option><option>Green</option><option>Blue</option>".html_safe, :
|
99
|
+
# select_tag "colors", "<option>Red</option><option>Green</option><option>Blue</option>".html_safe, multiple: true
|
101
100
|
# # => <select id="colors" multiple="multiple" name="colors[]"><option>Red</option>
|
102
101
|
# # <option>Green</option><option>Blue</option></select>
|
103
102
|
#
|
104
|
-
# select_tag "locations", "<option>Home</option><option selected=
|
103
|
+
# select_tag "locations", "<option>Home</option><option selected='selected'>Work</option><option>Out</option>".html_safe
|
105
104
|
# # => <select id="locations" name="locations"><option>Home</option><option selected='selected'>Work</option>
|
106
105
|
# # <option>Out</option></select>
|
107
106
|
#
|
108
|
-
# select_tag "access", "<option>Read</option><option>Write</option>".html_safe, :
|
107
|
+
# select_tag "access", "<option>Read</option><option>Write</option>".html_safe, multiple: true, class: 'form_input'
|
109
108
|
# # => <select class="form_input" id="access" multiple="multiple" name="access[]"><option>Read</option>
|
110
109
|
# # <option>Write</option></select>
|
111
110
|
#
|
112
|
-
# select_tag "people", options_from_collection_for_select(@people, "id", "name"), :
|
111
|
+
# select_tag "people", options_from_collection_for_select(@people, "id", "name"), include_blank: true
|
113
112
|
# # => <select id="people" name="people"><option value=""></option><option value="1">David</option></select>
|
114
113
|
#
|
115
|
-
# select_tag "people", options_from_collection_for_select(@people, "id", "name"), :
|
114
|
+
# select_tag "people", options_from_collection_for_select(@people, "id", "name"), prompt: "Select something"
|
116
115
|
# # => <select id="people" name="people"><option value="">Select something</option><option value="1">David</option></select>
|
117
116
|
#
|
118
|
-
# select_tag "destination", "<option>NYC</option><option>Paris</option><option>Rome</option>".html_safe, :
|
117
|
+
# select_tag "destination", "<option>NYC</option><option>Paris</option><option>Rome</option>".html_safe, disabled: true
|
119
118
|
# # => <select disabled="disabled" id="destination" name="destination"><option>NYC</option>
|
120
119
|
# # <option>Paris</option><option>Rome</option></select>
|
120
|
+
#
|
121
|
+
# select_tag "credit_card", options_for_select([ "VISA", "MasterCard" ], "MasterCard")
|
122
|
+
# # => <select id="credit_card" name="credit_card"><option>VISA</option>
|
123
|
+
# # <option selected="selected">MasterCard</option></select>
|
121
124
|
def select_tag(name, option_tags = nil, options = {})
|
122
125
|
option_tags ||= ""
|
123
126
|
html_name = (options[:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name
|
@@ -150,22 +153,22 @@ module ActionView
|
|
150
153
|
# text_field_tag 'query', 'Enter your search query here'
|
151
154
|
# # => <input id="query" name="query" type="text" value="Enter your search query here" />
|
152
155
|
#
|
153
|
-
# text_field_tag 'search', nil, :
|
156
|
+
# text_field_tag 'search', nil, placeholder: 'Enter search term...'
|
154
157
|
# # => <input id="search" name="search" placeholder="Enter search term..." type="text" />
|
155
158
|
#
|
156
|
-
# text_field_tag 'request', nil, :
|
159
|
+
# text_field_tag 'request', nil, class: 'special_input'
|
157
160
|
# # => <input class="special_input" id="request" name="request" type="text" />
|
158
161
|
#
|
159
|
-
# text_field_tag 'address', '', :
|
162
|
+
# text_field_tag 'address', '', size: 75
|
160
163
|
# # => <input id="address" name="address" size="75" type="text" value="" />
|
161
164
|
#
|
162
|
-
# text_field_tag 'zip', nil, :
|
165
|
+
# text_field_tag 'zip', nil, maxlength: 5
|
163
166
|
# # => <input id="zip" maxlength="5" name="zip" type="text" />
|
164
167
|
#
|
165
|
-
# text_field_tag 'payment_amount', '$0.00', :
|
168
|
+
# text_field_tag 'payment_amount', '$0.00', disabled: true
|
166
169
|
# # => <input disabled="disabled" id="payment_amount" name="payment_amount" type="text" value="$0.00" />
|
167
170
|
#
|
168
|
-
# text_field_tag 'ip', '0.0.0.0', :
|
171
|
+
# text_field_tag 'ip', '0.0.0.0', maxlength: 15, size: 20, class: "ip-input"
|
169
172
|
# # => <input class="ip-input" id="ip" maxlength="15" name="ip" size="20" type="text" value="0.0.0.0" />
|
170
173
|
def text_field_tag(name, value = nil, options = {})
|
171
174
|
tag :input, { "type" => "text", "name" => name, "id" => sanitize_to_id(name), "value" => value }.update(options.stringify_keys)
|
@@ -183,7 +186,7 @@ module ActionView
|
|
183
186
|
# label_tag 'name', 'Your name'
|
184
187
|
# # => <label for="name">Your name</label>
|
185
188
|
#
|
186
|
-
# label_tag 'name', nil, :
|
189
|
+
# label_tag 'name', nil, class: 'small_label'
|
187
190
|
# # => <label for="name" class="small_label">Name</label>
|
188
191
|
def label_tag(name = nil, content_or_options = nil, options = nil, &block)
|
189
192
|
if block_given? && content_or_options.is_a?(Hash)
|
@@ -209,7 +212,7 @@ module ActionView
|
|
209
212
|
# hidden_field_tag 'token', 'VUBJKB23UIVI1UU1VOBVI@'
|
210
213
|
# # => <input id="token" name="token" type="hidden" value="VUBJKB23UIVI1UU1VOBVI@" />
|
211
214
|
#
|
212
|
-
# hidden_field_tag 'collected_input', '', :
|
215
|
+
# hidden_field_tag 'collected_input', '', onchange: "alert('Input collected!')"
|
213
216
|
# # => <input id="collected_input" name="collected_input" onchange="alert('Input collected!')"
|
214
217
|
# # type="hidden" value="" />
|
215
218
|
def hidden_field_tag(name, value = nil, options = {})
|
@@ -219,7 +222,7 @@ module ActionView
|
|
219
222
|
# Creates a file upload field. If you are using file uploads then you will also need
|
220
223
|
# to set the multipart option for the form tag:
|
221
224
|
#
|
222
|
-
# <%= form_tag '/upload', :
|
225
|
+
# <%= form_tag '/upload', multipart: true do %>
|
223
226
|
# <label for="file">File to Upload</label> <%= file_field_tag "file" %>
|
224
227
|
# <%= submit_tag %>
|
225
228
|
# <% end %>
|
@@ -230,24 +233,26 @@ module ActionView
|
|
230
233
|
# ==== Options
|
231
234
|
# * Creates standard HTML attributes for the tag.
|
232
235
|
# * <tt>:disabled</tt> - If set to true, the user will not be able to use this input.
|
236
|
+
# * <tt>:multiple</tt> - If set to true, *in most updated browsers* the user will be allowed to select multiple files.
|
237
|
+
# * <tt>:accept</tt> - If set to one or multiple mime-types, the user will be suggested a filter when choosing a file. You still need to set up model validations.
|
233
238
|
#
|
234
239
|
# ==== Examples
|
235
240
|
# file_field_tag 'attachment'
|
236
241
|
# # => <input id="attachment" name="attachment" type="file" />
|
237
242
|
#
|
238
|
-
# file_field_tag 'avatar', :
|
243
|
+
# file_field_tag 'avatar', class: 'profile_input'
|
239
244
|
# # => <input class="profile_input" id="avatar" name="avatar" type="file" />
|
240
245
|
#
|
241
|
-
# file_field_tag 'picture', :
|
246
|
+
# file_field_tag 'picture', disabled: true
|
242
247
|
# # => <input disabled="disabled" id="picture" name="picture" type="file" />
|
243
248
|
#
|
244
|
-
# file_field_tag 'resume', :
|
249
|
+
# file_field_tag 'resume', value: '~/resume.doc'
|
245
250
|
# # => <input id="resume" name="resume" type="file" value="~/resume.doc" />
|
246
251
|
#
|
247
|
-
# file_field_tag 'user_pic', :
|
252
|
+
# file_field_tag 'user_pic', accept: 'image/png,image/gif,image/jpeg'
|
248
253
|
# # => <input accept="image/png,image/gif,image/jpeg" id="user_pic" name="user_pic" type="file" />
|
249
254
|
#
|
250
|
-
# file_field_tag 'file', :
|
255
|
+
# file_field_tag 'file', accept: 'text/html', class: 'upload', value: 'index.html'
|
251
256
|
# # => <input accept="text/html" class="upload" id="file" name="file" type="file" value="index.html" />
|
252
257
|
def file_field_tag(name, options = {})
|
253
258
|
text_field_tag(name, nil, options.update("type" => "file"))
|
@@ -268,19 +273,19 @@ module ActionView
|
|
268
273
|
# password_field_tag 'secret', 'Your secret here'
|
269
274
|
# # => <input id="secret" name="secret" type="password" value="Your secret here" />
|
270
275
|
#
|
271
|
-
# password_field_tag 'masked', nil, :
|
276
|
+
# password_field_tag 'masked', nil, class: 'masked_input_field'
|
272
277
|
# # => <input class="masked_input_field" id="masked" name="masked" type="password" />
|
273
278
|
#
|
274
|
-
# password_field_tag 'token', '', :
|
279
|
+
# password_field_tag 'token', '', size: 15
|
275
280
|
# # => <input id="token" name="token" size="15" type="password" value="" />
|
276
281
|
#
|
277
|
-
# password_field_tag 'key', nil, :
|
282
|
+
# password_field_tag 'key', nil, maxlength: 16
|
278
283
|
# # => <input id="key" maxlength="16" name="key" type="password" />
|
279
284
|
#
|
280
|
-
# password_field_tag 'confirm_pass', nil, :
|
285
|
+
# password_field_tag 'confirm_pass', nil, disabled: true
|
281
286
|
# # => <input disabled="disabled" id="confirm_pass" name="confirm_pass" type="password" />
|
282
287
|
#
|
283
|
-
# password_field_tag 'pin', '1234', :
|
288
|
+
# password_field_tag 'pin', '1234', maxlength: 4, size: 6, class: "pin_input"
|
284
289
|
# # => <input class="pin_input" id="pin" maxlength="4" name="pin" size="6" type="password" value="1234" />
|
285
290
|
def password_field_tag(name = "password", value = nil, options = {})
|
286
291
|
text_field_tag(name, value, options.update("type" => "password"))
|
@@ -304,16 +309,16 @@ module ActionView
|
|
304
309
|
# text_area_tag 'bio', @user.bio
|
305
310
|
# # => <textarea id="bio" name="bio">This is my biography.</textarea>
|
306
311
|
#
|
307
|
-
# text_area_tag 'body', nil, :
|
312
|
+
# text_area_tag 'body', nil, rows: 10, cols: 25
|
308
313
|
# # => <textarea cols="25" id="body" name="body" rows="10"></textarea>
|
309
314
|
#
|
310
|
-
# text_area_tag 'body', nil, :
|
315
|
+
# text_area_tag 'body', nil, size: "25x10"
|
311
316
|
# # => <textarea name="body" id="body" cols="25" rows="10"></textarea>
|
312
317
|
#
|
313
|
-
# text_area_tag 'description', "Description goes here.", :
|
318
|
+
# text_area_tag 'description', "Description goes here.", disabled: true
|
314
319
|
# # => <textarea disabled="disabled" id="description" name="description">Description goes here.</textarea>
|
315
320
|
#
|
316
|
-
# text_area_tag 'comment', nil, :
|
321
|
+
# text_area_tag 'comment', nil, class: 'comment_input'
|
317
322
|
# # => <textarea class="comment_input" id="comment" name="comment"></textarea>
|
318
323
|
def text_area_tag(name, content = nil, options = {})
|
319
324
|
options = options.stringify_keys
|
@@ -322,7 +327,7 @@ module ActionView
|
|
322
327
|
options["cols"], options["rows"] = size.split("x") if size.respond_to?(:split)
|
323
328
|
end
|
324
329
|
|
325
|
-
escape = options.
|
330
|
+
escape = options.delete("escape") { true }
|
326
331
|
content = ERB::Util.html_escape(content) if escape
|
327
332
|
|
328
333
|
content_tag :textarea, content.to_s.html_safe, { "name" => name, "id" => sanitize_to_id(name) }.update(options)
|
@@ -344,10 +349,10 @@ module ActionView
|
|
344
349
|
# check_box_tag 'receive_email', 'yes', true
|
345
350
|
# # => <input checked="checked" id="receive_email" name="receive_email" type="checkbox" value="yes" />
|
346
351
|
#
|
347
|
-
# check_box_tag 'tos', 'yes', false, :
|
352
|
+
# check_box_tag 'tos', 'yes', false, class: 'accept_tos'
|
348
353
|
# # => <input class="accept_tos" id="tos" name="tos" type="checkbox" value="yes" />
|
349
354
|
#
|
350
|
-
# check_box_tag 'eula', 'accepted', false, :
|
355
|
+
# check_box_tag 'eula', 'accepted', false, disabled: true
|
351
356
|
# # => <input disabled="disabled" id="eula" name="eula" type="checkbox" value="accepted" />
|
352
357
|
def check_box_tag(name, value = "1", checked = false, options = {})
|
353
358
|
html_options = { "type" => "checkbox", "name" => name, "id" => sanitize_to_id(name), "value" => value }.update(options.stringify_keys)
|
@@ -369,10 +374,10 @@ module ActionView
|
|
369
374
|
# radio_button_tag 'receive_updates', 'no', true
|
370
375
|
# # => <input checked="checked" id="receive_updates_no" name="receive_updates" type="radio" value="no" />
|
371
376
|
#
|
372
|
-
# radio_button_tag 'time_slot', "3:00 p.m.", false, :
|
377
|
+
# radio_button_tag 'time_slot', "3:00 p.m.", false, disabled: true
|
373
378
|
# # => <input disabled="disabled" id="time_slot_300_pm" name="time_slot" type="radio" value="3:00 p.m." />
|
374
379
|
#
|
375
|
-
# radio_button_tag 'color', "green", true, :
|
380
|
+
# radio_button_tag 'color', "green", true, class: "color_input"
|
376
381
|
# # => <input checked="checked" class="color_input" id="color_green" name="color" type="radio" value="green" />
|
377
382
|
def radio_button_tag(name, value, checked = false, options = {})
|
378
383
|
html_options = { "type" => "radio", "name" => name, "id" => "#{sanitize_to_id(name)}_#{sanitize_to_id(value)}", "value" => value }.update(options.stringify_keys)
|
@@ -383,14 +388,18 @@ module ActionView
|
|
383
388
|
# Creates a submit button with the text <tt>value</tt> as the caption.
|
384
389
|
#
|
385
390
|
# ==== Options
|
386
|
-
# * <tt>:
|
391
|
+
# * <tt>:data</tt> - This option can be used to add custom data attributes.
|
392
|
+
# * <tt>:disabled</tt> - If true, the user will not be able to use this input.
|
393
|
+
# * Any other key creates standard HTML options for the tag.
|
394
|
+
#
|
395
|
+
# ==== Data attributes
|
396
|
+
#
|
397
|
+
# * <tt>confirm: 'question?'</tt> - If present the unobtrusive JavaScript
|
387
398
|
# drivers will provide a prompt with the question specified. If the user accepts,
|
388
399
|
# the form is processed normally, otherwise no action is taken.
|
389
|
-
# * <tt>:disabled</tt> - If true, the user will not be able to use this input.
|
390
400
|
# * <tt>:disable_with</tt> - Value of this parameter will be used as the value for a
|
391
401
|
# disabled version of the submit button when the form is submitted. This feature is
|
392
402
|
# provided by the unobtrusive JavaScript driver.
|
393
|
-
# * Any other key creates standard HTML options for the tag.
|
394
403
|
#
|
395
404
|
# ==== Examples
|
396
405
|
# submit_tag
|
@@ -399,29 +408,37 @@ module ActionView
|
|
399
408
|
# submit_tag "Edit this article"
|
400
409
|
# # => <input name="commit" type="submit" value="Edit this article" />
|
401
410
|
#
|
402
|
-
# submit_tag "Save edits", :
|
411
|
+
# submit_tag "Save edits", disabled: true
|
403
412
|
# # => <input disabled="disabled" name="commit" type="submit" value="Save edits" />
|
404
413
|
#
|
405
|
-
# submit_tag "Complete sale", :disable_with
|
414
|
+
# submit_tag "Complete sale", data: { disable_with: "Please wait..." }
|
406
415
|
# # => <input name="commit" data-disable-with="Please wait..." type="submit" value="Complete sale" />
|
407
416
|
#
|
408
|
-
# submit_tag nil, :
|
417
|
+
# submit_tag nil, class: "form_submit"
|
409
418
|
# # => <input class="form_submit" name="commit" type="submit" />
|
410
419
|
#
|
411
|
-
# submit_tag "Edit", :
|
412
|
-
# # => <input class="edit_button"
|
420
|
+
# submit_tag "Edit", class: "edit_button"
|
421
|
+
# # => <input class="edit_button" name="commit" type="submit" value="Edit" />
|
413
422
|
#
|
414
|
-
# submit_tag "Save", :confirm
|
423
|
+
# submit_tag "Save", data: { confirm: "Are you sure?" }
|
415
424
|
# # => <input name='commit' type='submit' value='Save' data-confirm="Are you sure?" />
|
416
425
|
#
|
417
426
|
def submit_tag(value = "Save changes", options = {})
|
418
427
|
options = options.stringify_keys
|
419
428
|
|
420
429
|
if disable_with = options.delete("disable_with")
|
430
|
+
message = ":disable_with option is deprecated and will be removed from Rails 4.1. " \
|
431
|
+
"Use 'data: { disable_with: \'Text\' }' instead."
|
432
|
+
ActiveSupport::Deprecation.warn message
|
433
|
+
|
421
434
|
options["data-disable-with"] = disable_with
|
422
435
|
end
|
423
436
|
|
424
437
|
if confirm = options.delete("confirm")
|
438
|
+
message = ":confirm option is deprecated and will be removed from Rails 4.1. " \
|
439
|
+
"Use 'data: { confirm: \'Text\' }' instead'."
|
440
|
+
ActiveSupport::Deprecation.warn message
|
441
|
+
|
425
442
|
options["data-confirm"] = confirm
|
426
443
|
end
|
427
444
|
|
@@ -436,30 +453,34 @@ module ActionView
|
|
436
453
|
# so this helper will also accept a block.
|
437
454
|
#
|
438
455
|
# ==== Options
|
439
|
-
# * <tt>:
|
456
|
+
# * <tt>:data</tt> - This option can be used to add custom data attributes.
|
457
|
+
# * <tt>:disabled</tt> - If true, the user will not be able to
|
458
|
+
# use this input.
|
459
|
+
# * Any other key creates standard HTML options for the tag.
|
460
|
+
#
|
461
|
+
# ==== Data attributes
|
462
|
+
#
|
463
|
+
# * <tt>confirm: 'question?'</tt> - If present, the
|
440
464
|
# unobtrusive JavaScript drivers will provide a prompt with
|
441
465
|
# the question specified. If the user accepts, the form is
|
442
466
|
# processed normally, otherwise no action is taken.
|
443
|
-
# * <tt>:disabled</tt> - If true, the user will not be able to
|
444
|
-
# use this input.
|
445
467
|
# * <tt>:disable_with</tt> - Value of this parameter will be
|
446
468
|
# used as the value for a disabled version of the submit
|
447
469
|
# button when the form is submitted. This feature is provided
|
448
470
|
# by the unobtrusive JavaScript driver.
|
449
|
-
# * Any other key creates standard HTML options for the tag.
|
450
471
|
#
|
451
472
|
# ==== Examples
|
452
473
|
# button_tag
|
453
474
|
# # => <button name="button" type="submit">Button</button>
|
454
475
|
#
|
455
|
-
# button_tag(:
|
476
|
+
# button_tag(type: 'button') do
|
456
477
|
# content_tag(:strong, 'Ask me!')
|
457
478
|
# end
|
458
479
|
# # => <button name="button" type="button">
|
459
480
|
# # <strong>Ask me!</strong>
|
460
481
|
# # </button>
|
461
482
|
#
|
462
|
-
# button_tag "Checkout", :disable_with => "Please wait..."
|
483
|
+
# button_tag "Checkout", data: { disable_with => "Please wait..." }
|
463
484
|
# # => <button data-disable-with="Please wait..." name="button" type="submit">Checkout</button>
|
464
485
|
#
|
465
486
|
def button_tag(content_or_options = nil, options = nil, &block)
|
@@ -468,10 +489,18 @@ module ActionView
|
|
468
489
|
options = options.stringify_keys
|
469
490
|
|
470
491
|
if disable_with = options.delete("disable_with")
|
492
|
+
message = ":disable_with option is deprecated and will be removed from Rails 4.1. " \
|
493
|
+
"Use 'data: { disable_with: \'Text\' }' instead."
|
494
|
+
ActiveSupport::Deprecation.warn message
|
495
|
+
|
471
496
|
options["data-disable-with"] = disable_with
|
472
497
|
end
|
473
498
|
|
474
499
|
if confirm = options.delete("confirm")
|
500
|
+
message = ":confirm option is deprecated and will be removed from Rails 4.1. " \
|
501
|
+
"Use 'data: { confirm: \'Text\' }' instead'."
|
502
|
+
ActiveSupport::Deprecation.warn message
|
503
|
+
|
475
504
|
options["data-confirm"] = confirm
|
476
505
|
end
|
477
506
|
|
@@ -485,32 +514,43 @@ module ActionView
|
|
485
514
|
# <tt>source</tt> is passed to AssetTagHelper#path_to_image
|
486
515
|
#
|
487
516
|
# ==== Options
|
488
|
-
# * <tt>:
|
489
|
-
# prompt with the question specified. If the user accepts, the form is
|
490
|
-
# processed normally, otherwise no action is taken.
|
517
|
+
# * <tt>:data</tt> - This option can be used to add custom data attributes.
|
491
518
|
# * <tt>:disabled</tt> - If set to true, the user will not be able to use this input.
|
492
519
|
# * Any other key creates standard HTML options for the tag.
|
493
520
|
#
|
521
|
+
# ==== Data attributes
|
522
|
+
#
|
523
|
+
# * <tt>confirm: 'question?'</tt> - This will add a JavaScript confirm
|
524
|
+
# prompt with the question specified. If the user accepts, the form is
|
525
|
+
# processed normally, otherwise no action is taken.
|
526
|
+
#
|
494
527
|
# ==== Examples
|
495
528
|
# image_submit_tag("login.png")
|
496
|
-
# # => <input src="/images/login.png" type="image" />
|
529
|
+
# # => <input alt="Login" src="/images/login.png" type="image" />
|
530
|
+
#
|
531
|
+
# image_submit_tag("purchase.png", disabled: true)
|
532
|
+
# # => <input alt="Purchase" disabled="disabled" src="/images/purchase.png" type="image" />
|
497
533
|
#
|
498
|
-
# image_submit_tag("
|
499
|
-
# # => <input
|
534
|
+
# image_submit_tag("search.png", class: 'search_button', alt: 'Find')
|
535
|
+
# # => <input alt="Find" class="search_button" src="/images/search.png" type="image" />
|
500
536
|
#
|
501
|
-
# image_submit_tag("
|
502
|
-
# # => <input class="
|
537
|
+
# image_submit_tag("agree.png", disabled: true, class: "agree_disagree_button")
|
538
|
+
# # => <input alt="Agree" class="agree_disagree_button" disabled="disabled" src="/images/agree.png" type="image" />
|
503
539
|
#
|
504
|
-
# image_submit_tag("
|
505
|
-
# # => <input
|
540
|
+
# image_submit_tag("save.png", data: { confirm: "Are you sure?" })
|
541
|
+
# # => <input alt="Save" src="/images/save.png" data-confirm="Are you sure?" type="image" />
|
506
542
|
def image_submit_tag(source, options = {})
|
507
543
|
options = options.stringify_keys
|
508
544
|
|
509
545
|
if confirm = options.delete("confirm")
|
546
|
+
message = ":confirm option is deprecated and will be removed from Rails 4.1. " \
|
547
|
+
"Use 'data: { confirm: \'Text\' }' instead'."
|
548
|
+
ActiveSupport::Deprecation.warn message
|
549
|
+
|
510
550
|
options["data-confirm"] = confirm
|
511
551
|
end
|
512
552
|
|
513
|
-
tag :input, { "type" => "image", "src" => path_to_image(source) }.update(options)
|
553
|
+
tag :input, { "alt" => image_alt(source), "type" => "image", "src" => path_to_image(source) }.update(options)
|
514
554
|
end
|
515
555
|
|
516
556
|
# Creates a field set for grouping HTML form elements.
|
@@ -529,18 +569,25 @@ module ActionView
|
|
529
569
|
# <% end %>
|
530
570
|
# # => <fieldset><legend>Your details</legend><p><input id="name" name="name" type="text" /></p></fieldset>
|
531
571
|
#
|
532
|
-
# <%= field_set_tag nil, :
|
572
|
+
# <%= field_set_tag nil, class: 'format' do %>
|
533
573
|
# <p><%= text_field_tag 'name' %></p>
|
534
574
|
# <% end %>
|
535
575
|
# # => <fieldset class="format"><p><input id="name" name="name" type="text" /></p></fieldset>
|
536
576
|
def field_set_tag(legend = nil, options = nil, &block)
|
537
|
-
content = capture(&block)
|
538
577
|
output = tag(:fieldset, options, true)
|
539
578
|
output.safe_concat(content_tag(:legend, legend)) unless legend.blank?
|
540
|
-
output.concat(
|
579
|
+
output.concat(capture(&block)) if block_given?
|
541
580
|
output.safe_concat("</fieldset>")
|
542
581
|
end
|
543
582
|
|
583
|
+
# Creates a text field of type "color".
|
584
|
+
#
|
585
|
+
# ==== Options
|
586
|
+
# * Accepts the same options as text_field_tag.
|
587
|
+
def color_field_tag(name, value = nil, options = {})
|
588
|
+
text_field_tag(name, value, options.stringify_keys.update("type" => "color"))
|
589
|
+
end
|
590
|
+
|
544
591
|
# Creates a text field of type "search".
|
545
592
|
#
|
546
593
|
# ==== Options
|
@@ -558,6 +605,69 @@ module ActionView
|
|
558
605
|
end
|
559
606
|
alias phone_field_tag telephone_field_tag
|
560
607
|
|
608
|
+
# Creates a text field of type "date".
|
609
|
+
#
|
610
|
+
# ==== Options
|
611
|
+
# * Accepts the same options as text_field_tag.
|
612
|
+
def date_field_tag(name, value = nil, options = {})
|
613
|
+
text_field_tag(name, value, options.stringify_keys.update("type" => "date"))
|
614
|
+
end
|
615
|
+
|
616
|
+
# Creates a text field of type "time".
|
617
|
+
#
|
618
|
+
# === Options
|
619
|
+
# * <tt>:min</tt> - The minimum acceptable value.
|
620
|
+
# * <tt>:max</tt> - The maximum acceptable value.
|
621
|
+
# * <tt>:step</tt> - The acceptable value granularity.
|
622
|
+
# * Otherwise accepts the same options as text_field_tag.
|
623
|
+
def time_field_tag(name, value = nil, options = {})
|
624
|
+
text_field_tag(name, value, options.stringify_keys.update("type" => "time"))
|
625
|
+
end
|
626
|
+
|
627
|
+
# Creates a text field of type "datetime".
|
628
|
+
#
|
629
|
+
# === Options
|
630
|
+
# * <tt>:min</tt> - The minimum acceptable value.
|
631
|
+
# * <tt>:max</tt> - The maximum acceptable value.
|
632
|
+
# * <tt>:step</tt> - The acceptable value granularity.
|
633
|
+
# * Otherwise accepts the same options as text_field_tag.
|
634
|
+
def datetime_field_tag(name, value = nil, options = {})
|
635
|
+
text_field_tag(name, value, options.stringify_keys.update("type" => "datetime"))
|
636
|
+
end
|
637
|
+
|
638
|
+
# Creates a text field of type "datetime-local".
|
639
|
+
#
|
640
|
+
# === Options
|
641
|
+
# * <tt>:min</tt> - The minimum acceptable value.
|
642
|
+
# * <tt>:max</tt> - The maximum acceptable value.
|
643
|
+
# * <tt>:step</tt> - The acceptable value granularity.
|
644
|
+
# * Otherwise accepts the same options as text_field_tag.
|
645
|
+
def datetime_local_field_tag(name, value = nil, options = {})
|
646
|
+
text_field_tag(name, value, options.stringify_keys.update("type" => "datetime-local"))
|
647
|
+
end
|
648
|
+
|
649
|
+
# Creates a text field of type "month".
|
650
|
+
#
|
651
|
+
# === Options
|
652
|
+
# * <tt>:min</tt> - The minimum acceptable value.
|
653
|
+
# * <tt>:max</tt> - The maximum acceptable value.
|
654
|
+
# * <tt>:step</tt> - The acceptable value granularity.
|
655
|
+
# * Otherwise accepts the same options as text_field_tag.
|
656
|
+
def month_field_tag(name, value = nil, options = {})
|
657
|
+
text_field_tag(name, value, options.stringify_keys.update("type" => "month"))
|
658
|
+
end
|
659
|
+
|
660
|
+
# Creates a text field of type "week".
|
661
|
+
#
|
662
|
+
# === Options
|
663
|
+
# * <tt>:min</tt> - The minimum acceptable value.
|
664
|
+
# * <tt>:max</tt> - The maximum acceptable value.
|
665
|
+
# * <tt>:step</tt> - The acceptable value granularity.
|
666
|
+
# * Otherwise accepts the same options as text_field_tag.
|
667
|
+
def week_field_tag(name, value = nil, options = {})
|
668
|
+
text_field_tag(name, value, options.stringify_keys.update("type" => "week"))
|
669
|
+
end
|
670
|
+
|
561
671
|
# Creates a text field of type "url".
|
562
672
|
#
|
563
673
|
# ==== Options
|
@@ -585,7 +695,7 @@ module ActionView
|
|
585
695
|
# * Otherwise accepts the same options as text_field_tag.
|
586
696
|
#
|
587
697
|
# ==== Examples
|
588
|
-
# number_field_tag 'quantity', nil, :
|
698
|
+
# number_field_tag 'quantity', nil, in: 1...10
|
589
699
|
# # => <input id="quantity" name="quantity" min="1" max="9" type="number" />
|
590
700
|
def number_field_tag(name, value = nil, options = {})
|
591
701
|
options = options.stringify_keys
|
@@ -647,7 +757,7 @@ module ActionView
|
|
647
757
|
token_tag(authenticity_token)
|
648
758
|
else
|
649
759
|
html_options["method"] = "post"
|
650
|
-
|
760
|
+
method_tag(method) + token_tag(authenticity_token)
|
651
761
|
end
|
652
762
|
|
653
763
|
tags = utf8_enforcer_tag << method_tag
|
@@ -656,26 +766,16 @@ module ActionView
|
|
656
766
|
|
657
767
|
def form_tag_html(html_options)
|
658
768
|
extra_tags = extra_tags_for_form(html_options)
|
659
|
-
|
769
|
+
tag(:form, html_options, true) + extra_tags
|
660
770
|
end
|
661
771
|
|
662
772
|
def form_tag_in_block(html_options, &block)
|
663
773
|
content = capture(&block)
|
664
|
-
output =
|
665
|
-
output.safe_concat(form_tag_html(html_options))
|
774
|
+
output = form_tag_html(html_options)
|
666
775
|
output << content
|
667
776
|
output.safe_concat("</form>")
|
668
777
|
end
|
669
778
|
|
670
|
-
def token_tag(token)
|
671
|
-
if token == false || !protect_against_forgery?
|
672
|
-
''
|
673
|
-
else
|
674
|
-
token ||= form_authenticity_token
|
675
|
-
tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, :value => token)
|
676
|
-
end
|
677
|
-
end
|
678
|
-
|
679
779
|
# see http://www.w3.org/TR/html4/types.html#type-name
|
680
780
|
def sanitize_to_id(name)
|
681
781
|
name.to_s.gsub(']','').gsub(/[^-a-zA-Z0-9:.]/, "_")
|