actionview 7.0.1 → 7.1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +340 -197
- data/MIT-LICENSE +1 -1
- data/README.rdoc +3 -3
- data/app/assets/javascripts/rails-ujs.esm.js +686 -0
- data/app/assets/javascripts/rails-ujs.js +630 -0
- data/lib/action_view/base.rb +33 -12
- data/lib/action_view/buffers.rb +106 -8
- data/lib/action_view/cache_expiry.rb +40 -43
- data/lib/action_view/context.rb +1 -1
- data/lib/action_view/deprecator.rb +7 -0
- data/lib/action_view/digestor.rb +1 -1
- data/lib/action_view/gem_version.rb +4 -4
- data/lib/action_view/helpers/active_model_helper.rb +1 -1
- data/lib/action_view/helpers/asset_tag_helper.rb +137 -52
- data/lib/action_view/helpers/asset_url_helper.rb +13 -12
- data/lib/action_view/helpers/atom_feed_helper.rb +5 -5
- data/lib/action_view/helpers/cache_helper.rb +3 -9
- data/lib/action_view/helpers/capture_helper.rb +32 -12
- data/lib/action_view/helpers/content_exfiltration_prevention_helper.rb +70 -0
- data/lib/action_view/helpers/controller_helper.rb +6 -0
- data/lib/action_view/helpers/csp_helper.rb +2 -2
- data/lib/action_view/helpers/csrf_helper.rb +3 -3
- data/lib/action_view/helpers/date_helper.rb +76 -64
- data/lib/action_view/helpers/debug_helper.rb +3 -3
- data/lib/action_view/helpers/form_helper.rb +72 -37
- data/lib/action_view/helpers/form_options_helper.rb +6 -3
- data/lib/action_view/helpers/form_tag_helper.rb +94 -50
- data/lib/action_view/helpers/javascript_helper.rb +1 -0
- data/lib/action_view/helpers/number_helper.rb +39 -331
- data/lib/action_view/helpers/output_safety_helper.rb +4 -4
- data/lib/action_view/helpers/rendering_helper.rb +5 -6
- data/lib/action_view/helpers/sanitize_helper.rb +52 -22
- data/lib/action_view/helpers/tag_helper.rb +27 -16
- data/lib/action_view/helpers/tags/base.rb +11 -52
- data/lib/action_view/helpers/tags/collection_check_boxes.rb +1 -0
- data/lib/action_view/helpers/tags/collection_radio_buttons.rb +1 -0
- data/lib/action_view/helpers/tags/collection_select.rb +3 -0
- data/lib/action_view/helpers/tags/date_field.rb +1 -1
- data/lib/action_view/helpers/tags/date_select.rb +2 -0
- data/lib/action_view/helpers/tags/datetime_field.rb +14 -6
- data/lib/action_view/helpers/tags/datetime_local_field.rb +11 -2
- data/lib/action_view/helpers/tags/grouped_collection_select.rb +3 -0
- data/lib/action_view/helpers/tags/month_field.rb +1 -1
- data/lib/action_view/helpers/tags/select.rb +4 -1
- data/lib/action_view/helpers/tags/select_renderer.rb +56 -0
- data/lib/action_view/helpers/tags/time_field.rb +1 -1
- data/lib/action_view/helpers/tags/time_zone_select.rb +3 -0
- data/lib/action_view/helpers/tags/week_field.rb +1 -1
- data/lib/action_view/helpers/tags/weekday_select.rb +3 -0
- data/lib/action_view/helpers/tags.rb +2 -0
- data/lib/action_view/helpers/text_helper.rb +157 -85
- data/lib/action_view/helpers/translation_helper.rb +6 -6
- data/lib/action_view/helpers/url_helper.rb +90 -65
- data/lib/action_view/helpers.rb +2 -0
- data/lib/action_view/layouts.rb +15 -10
- data/lib/action_view/log_subscriber.rb +49 -32
- data/lib/action_view/lookup_context.rb +29 -13
- data/lib/action_view/path_registry.rb +57 -0
- data/lib/action_view/path_set.rb +13 -14
- data/lib/action_view/railtie.rb +26 -3
- data/lib/action_view/record_identifier.rb +16 -9
- data/lib/action_view/renderer/abstract_renderer.rb +1 -1
- data/lib/action_view/renderer/collection_renderer.rb +10 -2
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +21 -3
- data/lib/action_view/renderer/partial_renderer.rb +3 -2
- data/lib/action_view/renderer/renderer.rb +2 -0
- data/lib/action_view/renderer/streaming_template_renderer.rb +3 -2
- data/lib/action_view/renderer/template_renderer.rb +3 -2
- data/lib/action_view/rendering.rb +24 -6
- data/lib/action_view/ripper_ast_parser.rb +6 -6
- data/lib/action_view/routing_url_for.rb +7 -4
- data/lib/action_view/template/error.rb +14 -1
- data/lib/action_view/template/handlers/builder.rb +4 -4
- data/lib/action_view/template/handlers/erb/erubi.rb +23 -27
- data/lib/action_view/template/handlers/erb.rb +73 -1
- data/lib/action_view/template/handlers.rb +1 -1
- data/lib/action_view/template/html.rb +1 -1
- data/lib/action_view/template/raw_file.rb +1 -1
- data/lib/action_view/template/renderable.rb +1 -1
- data/lib/action_view/template/resolver.rb +15 -5
- data/lib/action_view/template/text.rb +1 -1
- data/lib/action_view/template/types.rb +25 -34
- data/lib/action_view/template.rb +242 -54
- data/lib/action_view/template_path.rb +2 -0
- data/lib/action_view/test_case.rb +176 -21
- data/lib/action_view/unbound_template.rb +15 -5
- data/lib/action_view/version.rb +1 -1
- data/lib/action_view/view_paths.rb +19 -28
- data/lib/action_view.rb +4 -1
- data/lib/assets/compiled/rails-ujs.js +36 -5
- metadata +27 -27
@@ -13,8 +13,9 @@ require "active_support/core_ext/string/output_safety"
|
|
13
13
|
require "active_support/core_ext/string/inflections"
|
14
14
|
|
15
15
|
module ActionView
|
16
|
-
# = Action View Form Helpers
|
17
16
|
module Helpers # :nodoc:
|
17
|
+
# = Action View Form \Helpers
|
18
|
+
#
|
18
19
|
# Form helpers are designed to make working with resources much easier
|
19
20
|
# compared to using vanilla HTML.
|
20
21
|
#
|
@@ -28,7 +29,7 @@ module ActionView
|
|
28
29
|
# when the form is initially displayed, input fields corresponding to attributes
|
29
30
|
# of the resource should show the current values of those attributes.
|
30
31
|
#
|
31
|
-
# In Rails, this is usually achieved by creating the form using +form_for+ and
|
32
|
+
# In \Rails, this is usually achieved by creating the form using +form_for+ and
|
32
33
|
# a number of related helper methods. +form_for+ generates an appropriate <tt>form</tt>
|
33
34
|
# tag and yields a form builder object that knows the model the form is about.
|
34
35
|
# Input fields are created by calling methods defined on the form builder, which
|
@@ -122,7 +123,7 @@ module ActionView
|
|
122
123
|
# of a specific model object.
|
123
124
|
#
|
124
125
|
# The method can be used in several slightly different ways, depending on
|
125
|
-
# how much you wish to rely on Rails to infer automatically from the model
|
126
|
+
# how much you wish to rely on \Rails to infer automatically from the model
|
126
127
|
# how the form should be constructed. For a generic model object, a form
|
127
128
|
# can be created by passing +form_for+ a string or symbol representing
|
128
129
|
# the object we are concerned with:
|
@@ -251,7 +252,7 @@ module ActionView
|
|
251
252
|
# form is going to be sent. However, further simplification is possible
|
252
253
|
# if the record passed to +form_for+ is a _resource_, i.e. it corresponds
|
253
254
|
# to a set of RESTful routes, e.g. defined using the +resources+ method
|
254
|
-
# in <tt>config/routes.rb</tt>. In this case Rails will simply infer the
|
255
|
+
# in <tt>config/routes.rb</tt>. In this case \Rails will simply infer the
|
255
256
|
# appropriate URL from the record itself. For example,
|
256
257
|
#
|
257
258
|
# <%= form_for @post do |f| %>
|
@@ -496,7 +497,7 @@ module ActionView
|
|
496
497
|
# <%= form.text_field :title %>
|
497
498
|
# <% end %>
|
498
499
|
# # =>
|
499
|
-
# <form method="post"
|
500
|
+
# <form method="post">
|
500
501
|
# <input type="text" name="title">
|
501
502
|
# </form>
|
502
503
|
#
|
@@ -555,7 +556,7 @@ module ActionView
|
|
555
556
|
# is a _resource_. It corresponds to a set of RESTful routes, most likely
|
556
557
|
# defined via +resources+ in <tt>config/routes.rb</tt>.
|
557
558
|
#
|
558
|
-
# So when passing such a model record, Rails infers the URL and method.
|
559
|
+
# So when passing such a model record, \Rails infers the URL and method.
|
559
560
|
#
|
560
561
|
# <%= form_with model: @post do |form| %>
|
561
562
|
# ...
|
@@ -618,12 +619,12 @@ module ActionView
|
|
618
619
|
# * <tt>:local</tt> - Whether to use standard HTTP form submission.
|
619
620
|
# When set to <tt>true</tt>, the form is submitted via standard HTTP.
|
620
621
|
# When set to <tt>false</tt>, the form is submitted as a "remote form", which
|
621
|
-
# is handled by Rails UJS as an XHR. When unspecified, the behavior is derived
|
622
|
+
# is handled by \Rails UJS as an XHR. When unspecified, the behavior is derived
|
622
623
|
# from <tt>config.action_view.form_with_generates_remote_forms</tt> where the
|
623
624
|
# config's value is actually the inverse of what <tt>local</tt>'s value would be.
|
624
|
-
# As of Rails 6.1, that configuration option defaults to <tt>false</tt>
|
625
|
+
# As of \Rails 6.1, that configuration option defaults to <tt>false</tt>
|
625
626
|
# (which has the equivalent effect of passing <tt>local: true</tt>).
|
626
|
-
# In previous versions of Rails, that configuration option defaults to
|
627
|
+
# In previous versions of \Rails, that configuration option defaults to
|
627
628
|
# <tt>true</tt> (the equivalent of passing <tt>local: false</tt>).
|
628
629
|
# * <tt>:skip_enforcing_utf8</tt> - If set to true, a hidden input with name
|
629
630
|
# utf8 is not output.
|
@@ -756,10 +757,14 @@ module ActionView
|
|
756
757
|
|
757
758
|
if model
|
758
759
|
if url != false
|
759
|
-
url ||=
|
760
|
+
url ||= if format.nil?
|
761
|
+
polymorphic_path(model, {})
|
762
|
+
else
|
763
|
+
polymorphic_path(model, format: format)
|
764
|
+
end
|
760
765
|
end
|
761
766
|
|
762
|
-
model = _object_for_form_builder(model)
|
767
|
+
model = convert_to_model(_object_for_form_builder(model))
|
763
768
|
scope ||= model_name_from_record_or_class(model).param_key
|
764
769
|
end
|
765
770
|
|
@@ -1001,8 +1006,8 @@ module ActionView
|
|
1001
1006
|
# <% end %>
|
1002
1007
|
#
|
1003
1008
|
# When a collection is used you might want to know the index of each
|
1004
|
-
# object
|
1005
|
-
#
|
1009
|
+
# object in the array. For this purpose, the <tt>index</tt> method is
|
1010
|
+
# available in the FormBuilder object.
|
1006
1011
|
#
|
1007
1012
|
# <%= form_for @person do |person_form| %>
|
1008
1013
|
# ...
|
@@ -1014,9 +1019,10 @@ module ActionView
|
|
1014
1019
|
# <% end %>
|
1015
1020
|
#
|
1016
1021
|
# Note that fields_for will automatically generate a hidden field
|
1017
|
-
# to store the ID of the record
|
1018
|
-
# hidden field is not needed and you
|
1019
|
-
# to prevent fields_for from
|
1022
|
+
# to store the ID of the record if it responds to <tt>persisted?</tt>.
|
1023
|
+
# There are circumstances where this hidden field is not needed and you
|
1024
|
+
# can pass <tt>include_id: false</tt> to prevent fields_for from
|
1025
|
+
# rendering it automatically.
|
1020
1026
|
def fields_for(record_name, record_object = nil, options = {}, &block)
|
1021
1027
|
options = { model: record_object, allow_method_names_outside_object: false, skip_default_ids: false }.merge!(options)
|
1022
1028
|
|
@@ -1082,7 +1088,7 @@ module ActionView
|
|
1082
1088
|
|
1083
1089
|
# Returns a label tag tailored for labelling an input field for a specified attribute (identified by +method+) on an object
|
1084
1090
|
# assigned to the template (identified by +object+). The text of label will default to the attribute name unless a translation
|
1085
|
-
# is found in the current I18n locale (through helpers.label.<modelname>.<attribute>) or you specify it explicitly.
|
1091
|
+
# is found in the current I18n locale (through <tt>helpers.label.<modelname>.<attribute></tt>) or you specify it explicitly.
|
1086
1092
|
# Additional options on the label tag can be passed as a hash with +options+. These options will be tagged
|
1087
1093
|
# onto the HTML as an HTML element attribute as in the example shown, except for the <tt>:value</tt> option, which is designed to
|
1088
1094
|
# target labels for radio_button tags (where the value is used in the ID of the input tag).
|
@@ -1112,6 +1118,8 @@ module ActionView
|
|
1112
1118
|
# post:
|
1113
1119
|
# cost: "Total cost"
|
1114
1120
|
#
|
1121
|
+
# <code></code>
|
1122
|
+
#
|
1115
1123
|
# label(:post, :cost)
|
1116
1124
|
# # => <label for="post_cost">Total cost</label>
|
1117
1125
|
#
|
@@ -1237,7 +1245,7 @@ module ActionView
|
|
1237
1245
|
def file_field(object_name, method, options = {})
|
1238
1246
|
options = { include_hidden: multiple_file_field_include_hidden }.merge!(options)
|
1239
1247
|
|
1240
|
-
Tags::FileField.new(object_name, method, self, convert_direct_upload_option_to_url(
|
1248
|
+
Tags::FileField.new(object_name, method, self, convert_direct_upload_option_to_url(options.dup)).render
|
1241
1249
|
end
|
1242
1250
|
|
1243
1251
|
# Returns a textarea opening and closing tag set tailored for accessing a specified attribute (identified by +method+)
|
@@ -1310,7 +1318,7 @@ module ActionView
|
|
1310
1318
|
# ...
|
1311
1319
|
# <% end %>
|
1312
1320
|
#
|
1313
|
-
# because parameter name repetition is precisely what Rails seeks to distinguish
|
1321
|
+
# because parameter name repetition is precisely what \Rails seeks to distinguish
|
1314
1322
|
# the elements of the array. For each item with a checked check box you
|
1315
1323
|
# get an extra ghost item with only that attribute, assigned to "0".
|
1316
1324
|
#
|
@@ -1437,10 +1445,12 @@ module ActionView
|
|
1437
1445
|
# formatted by trying to call +strftime+ with "%H:%M" on the object's value.
|
1438
1446
|
# It is also possible to override this by passing the "value" option.
|
1439
1447
|
#
|
1440
|
-
#
|
1441
|
-
#
|
1448
|
+
# ==== Options
|
1449
|
+
#
|
1450
|
+
# Supports the same options as FormTagHelper#time_field_tag.
|
1451
|
+
#
|
1452
|
+
# ==== Examples
|
1442
1453
|
#
|
1443
|
-
# === Example
|
1444
1454
|
# time_field("task", "started_at")
|
1445
1455
|
# # => <input id="task_started_at" name="task[started_at]" type="time" />
|
1446
1456
|
#
|
@@ -1491,6 +1501,12 @@ module ActionView
|
|
1491
1501
|
# datetime_field("user", "born_on", min: "2014-05-20T00:00:00")
|
1492
1502
|
# # => <input id="user_born_on" name="user[born_on]" type="datetime-local" min="2014-05-20T00:00:00.000" />
|
1493
1503
|
#
|
1504
|
+
# By default, provided datetimes will be formatted including seconds. You can render just the date, hour,
|
1505
|
+
# and minute by passing <tt>include_seconds: false</tt>.
|
1506
|
+
#
|
1507
|
+
# @user.born_on = Time.current
|
1508
|
+
# datetime_field("user", "born_on", include_seconds: false)
|
1509
|
+
# # => <input id="user_born_on" name="user[born_on]" type="datetime-local" value="2014-05-20T14:35" />
|
1494
1510
|
def datetime_field(object_name, method, options = {})
|
1495
1511
|
Tags::DatetimeLocalField.new(object_name, method, self, options).render
|
1496
1512
|
end
|
@@ -1552,7 +1568,8 @@ module ActionView
|
|
1552
1568
|
# Returns an input tag of type "number".
|
1553
1569
|
#
|
1554
1570
|
# ==== Options
|
1555
|
-
#
|
1571
|
+
#
|
1572
|
+
# Supports the same options as FormTagHelper#number_field_tag.
|
1556
1573
|
def number_field(object_name, method, options = {})
|
1557
1574
|
Tags::NumberField.new(object_name, method, self, options).render
|
1558
1575
|
end
|
@@ -1560,7 +1577,8 @@ module ActionView
|
|
1560
1577
|
# Returns an input tag of type "range".
|
1561
1578
|
#
|
1562
1579
|
# ==== Options
|
1563
|
-
#
|
1580
|
+
#
|
1581
|
+
# Supports the same options as FormTagHelper#range_field_tag.
|
1564
1582
|
def range_field(object_name, method, options = {})
|
1565
1583
|
Tags::RangeField.new(object_name, method, self, options).render
|
1566
1584
|
end
|
@@ -1605,6 +1623,8 @@ module ActionView
|
|
1605
1623
|
end
|
1606
1624
|
end
|
1607
1625
|
|
1626
|
+
# = Action View Form Builder
|
1627
|
+
#
|
1608
1628
|
# A +FormBuilder+ object is associated with a particular model object and
|
1609
1629
|
# allows you to generate fields associated with the model object. The
|
1610
1630
|
# +FormBuilder+ object is yielded when using +form_for+ or +fields_for+.
|
@@ -1730,7 +1750,7 @@ module ActionView
|
|
1730
1750
|
# <tt><button></tt> element should be treated as the <tt><form></tt>
|
1731
1751
|
# element's submit button, regardless of where it exists in the DOM.
|
1732
1752
|
def id
|
1733
|
-
options.dig(:html, :id)
|
1753
|
+
options.dig(:html, :id) || options[:id]
|
1734
1754
|
end
|
1735
1755
|
|
1736
1756
|
# Generate an HTML <tt>id</tt> attribute value for the given field
|
@@ -1749,7 +1769,7 @@ module ActionView
|
|
1749
1769
|
# <tt>aria-describedby</tt> attribute referencing the <tt><span></tt>
|
1750
1770
|
# element, sharing a common <tt>id</tt> root (<tt>post_title</tt>, in this
|
1751
1771
|
# case).
|
1752
|
-
def field_id(method, *suffixes, namespace: @options[:namespace], index: @index)
|
1772
|
+
def field_id(method, *suffixes, namespace: @options[:namespace], index: @options[:index])
|
1753
1773
|
@template.field_id(@object_name, method, *suffixes, namespace: namespace, index: index)
|
1754
1774
|
end
|
1755
1775
|
|
@@ -1761,15 +1781,15 @@ module ActionView
|
|
1761
1781
|
#
|
1762
1782
|
# <%= form_for @post do |f| %>
|
1763
1783
|
# <%= f.text_field :title, name: f.field_name(:title, :subtitle) %>
|
1764
|
-
# <%# => <input type="text" name="post[title][subtitle]">
|
1784
|
+
# <%# => <input type="text" name="post[title][subtitle]"> %>
|
1765
1785
|
# <% end %>
|
1766
1786
|
#
|
1767
1787
|
# <%= form_for @post do |f| %>
|
1768
|
-
# <%= f.
|
1769
|
-
# <%# => <input type="text" name="post[tag][]">
|
1788
|
+
# <%= f.text_field :tag, name: f.field_name(:tag, multiple: true) %>
|
1789
|
+
# <%# => <input type="text" name="post[tag][]"> %>
|
1770
1790
|
# <% end %>
|
1771
1791
|
#
|
1772
|
-
def field_name(method, *methods, multiple: false, index: @index)
|
1792
|
+
def field_name(method, *methods, multiple: false, index: @options[:index])
|
1773
1793
|
object_name = @options.fetch(:as) { @object_name }
|
1774
1794
|
|
1775
1795
|
@template.field_name(object_name, method, *methods, index: index, multiple: multiple)
|
@@ -2069,6 +2089,18 @@ module ActionView
|
|
2069
2089
|
# DateHelper that are designed to work with an object as base, like
|
2070
2090
|
# FormOptionsHelper#collection_select and DateHelper#datetime_select.
|
2071
2091
|
#
|
2092
|
+
# +fields_for+ tries to be smart about parameters, but it can be confused if both
|
2093
|
+
# name and value parameters are provided and the provided value has the shape of an
|
2094
|
+
# option Hash. To remove the ambiguity, explicitly pass an option Hash, even if empty.
|
2095
|
+
#
|
2096
|
+
# <%= form_for @person do |person_form| %>
|
2097
|
+
# ...
|
2098
|
+
# <%= fields_for :permission, @person.permission, {} do |permission_fields| %>
|
2099
|
+
# Admin?: <%= check_box_tag permission_fields.field_name(:admin), @person.permission[:admin] %>
|
2100
|
+
# <% end %>
|
2101
|
+
# ...
|
2102
|
+
# <% end %>
|
2103
|
+
#
|
2072
2104
|
# === Nested Attributes Examples
|
2073
2105
|
#
|
2074
2106
|
# When the object belonging to the current scope has a nested attribute
|
@@ -2233,7 +2265,7 @@ module ActionView
|
|
2233
2265
|
# <% end %>
|
2234
2266
|
#
|
2235
2267
|
# When a collection is used you might want to know the index of each
|
2236
|
-
# object
|
2268
|
+
# object in the array. For this purpose, the <tt>index</tt> method
|
2237
2269
|
# is available in the FormBuilder object.
|
2238
2270
|
#
|
2239
2271
|
# <%= form_for @person do |person_form| %>
|
@@ -2249,8 +2281,9 @@ module ActionView
|
|
2249
2281
|
# to store the ID of the record. There are circumstances where this
|
2250
2282
|
# hidden field is not needed and you can pass <tt>include_id: false</tt>
|
2251
2283
|
# to prevent fields_for from rendering it automatically.
|
2252
|
-
def fields_for(record_name, record_object = nil, fields_options =
|
2253
|
-
fields_options, record_object = record_object, nil if record_object.is_a?(Hash) && record_object.extractable_options?
|
2284
|
+
def fields_for(record_name, record_object = nil, fields_options = nil, &block)
|
2285
|
+
fields_options, record_object = record_object, nil if fields_options.nil? && record_object.is_a?(Hash) && record_object.extractable_options?
|
2286
|
+
fields_options ||= {}
|
2254
2287
|
fields_options[:builder] ||= options[:builder]
|
2255
2288
|
fields_options[:namespace] = options[:namespace]
|
2256
2289
|
fields_options[:parent_builder] = self
|
@@ -2285,7 +2318,7 @@ module ActionView
|
|
2285
2318
|
@template.fields_for(record_name, record_object, fields_options, &block)
|
2286
2319
|
end
|
2287
2320
|
|
2288
|
-
# See the docs for the
|
2321
|
+
# See the docs for the ActionView::Helpers::FormHelper#fields helper method.
|
2289
2322
|
def fields(scope = nil, model: nil, **options, &block)
|
2290
2323
|
options[:allow_method_names_outside_object] = true
|
2291
2324
|
options[:skip_default_ids] = !FormHelper.form_with_generates_ids
|
@@ -2297,7 +2330,7 @@ module ActionView
|
|
2297
2330
|
|
2298
2331
|
# Returns a label tag tailored for labelling an input field for a specified attribute (identified by +method+) on an object
|
2299
2332
|
# assigned to the template (identified by +object+). The text of label will default to the attribute name unless a translation
|
2300
|
-
# is found in the current I18n locale (through helpers.label.<modelname>.<attribute>) or you specify it explicitly.
|
2333
|
+
# is found in the current I18n locale (through <tt>helpers.label.<modelname>.<attribute></tt>) or you specify it explicitly.
|
2301
2334
|
# Additional options on the label tag can be passed as a hash with +options+. These options will be tagged
|
2302
2335
|
# onto the HTML as an HTML element attribute as in the example shown, except for the <tt>:value</tt> option, which is designed to
|
2303
2336
|
# target labels for radio_button tags (where the value is used in the ID of the input tag).
|
@@ -2327,6 +2360,8 @@ module ActionView
|
|
2327
2360
|
# post:
|
2328
2361
|
# cost: "Total cost"
|
2329
2362
|
#
|
2363
|
+
# <code></code>
|
2364
|
+
#
|
2330
2365
|
# label(:cost)
|
2331
2366
|
# # => <label for="post_cost">Total cost</label>
|
2332
2367
|
#
|
@@ -2407,7 +2442,7 @@ module ActionView
|
|
2407
2442
|
# ...
|
2408
2443
|
# <% end %>
|
2409
2444
|
#
|
2410
|
-
# because parameter name repetition is precisely what Rails seeks to distinguish
|
2445
|
+
# because parameter name repetition is precisely what \Rails seeks to distinguish
|
2411
2446
|
# the elements of the array. For each item with a checked check box you
|
2412
2447
|
# get an extra ghost item with only that attribute, assigned to "0".
|
2413
2448
|
#
|
@@ -2490,7 +2525,7 @@ module ActionView
|
|
2490
2525
|
# * Creates standard HTML attributes for the tag.
|
2491
2526
|
# * <tt>:disabled</tt> - If set to true, the user will not be able to use this input.
|
2492
2527
|
# * <tt>:multiple</tt> - If set to true, *in most updated browsers* the user will be allowed to select multiple files.
|
2493
|
-
# * <tt>:include_hidden</tt> - When <tt>multiple: true</tt> and <tt>include_hidden: true</tt>, the field will be prefixed with an <tt><input type="hidden"></tt> field with an empty value to support submitting an empty collection of files.
|
2528
|
+
# * <tt>:include_hidden</tt> - When <tt>multiple: true</tt> and <tt>include_hidden: true</tt>, the field will be prefixed with an <tt><input type="hidden"></tt> field with an empty value to support submitting an empty collection of files. Since <tt>include_hidden</tt> will default to <tt>config.active_storage.multiple_file_field_include_hidden</tt> if you don't specify <tt>include_hidden</tt>, you will need to pass <tt>include_hidden: false</tt> to prevent submitting an empty collection of files when passing <tt>multiple: true</tt>.
|
2494
2529
|
# * <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.
|
2495
2530
|
#
|
2496
2531
|
# ==== Examples
|
@@ -8,8 +8,9 @@ require "active_support/core_ext/array/wrap"
|
|
8
8
|
require "action_view/helpers/text_helper"
|
9
9
|
|
10
10
|
module ActionView
|
11
|
-
# = Action View Form Option Helpers
|
12
11
|
module Helpers # :nodoc:
|
12
|
+
# = Action View Form Option \Helpers
|
13
|
+
#
|
13
14
|
# Provides a number of methods for turning different kinds of containers into a set of option tags.
|
14
15
|
#
|
15
16
|
# The <tt>collection_select</tt>, <tt>select</tt> and <tt>time_zone_select</tt> methods take an <tt>options</tt> parameter, a hash:
|
@@ -500,6 +501,8 @@ module ActionView
|
|
500
501
|
# <tt><optgroup></tt> label while the second value must be an array of options. The second value can be a
|
501
502
|
# nested array of text-value pairs. See <tt>options_for_select</tt> for more info.
|
502
503
|
# Ex. ["North America",[["United States","US"],["Canada","CA"]]]
|
504
|
+
# An optional third value can be provided as HTML attributes for the <tt>optgroup</tt>.
|
505
|
+
# Ex. ["North America",[["United States","US"],["Canada","CA"]], { disabled: "disabled" }]
|
503
506
|
# * +selected_key+ - A value equal to the +value+ attribute for one of the <tt><option></tt> tags,
|
504
507
|
# which will have the +selected+ attribute set. Note: It is possible for this value to match multiple options
|
505
508
|
# as you might have the same option in multiple groups. Each will then get <tt>selected="selected"</tt>.
|
@@ -598,9 +601,9 @@ module ActionView
|
|
598
601
|
#
|
599
602
|
# Options:
|
600
603
|
# * <tt>:index_as_value</tt> - Defaults to false, set to true to use the indexes from
|
601
|
-
#
|
604
|
+
# <tt>I18n.translate("date.day_names")</tt> as the values. By default, Sunday is always 0.
|
602
605
|
# * <tt>:day_format</tt> - The I18n key of the array to use for the weekday options.
|
603
|
-
#
|
606
|
+
# Defaults to +:day_names+, set to +:abbr_day_names+ for abbreviations.
|
604
607
|
# * <tt>:beginning_of_week</tt> - Defaults to Date.beginning_of_week.
|
605
608
|
#
|
606
609
|
# NOTE: Only the option tags are returned, you have to wrap this call in
|