actionview 5.2.3.rc1 → 6.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 actionview might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +115 -66
- data/MIT-LICENSE +1 -1
- data/README.rdoc +1 -1
- data/lib/action_view.rb +1 -1
- data/lib/action_view/buffers.rb +15 -0
- data/lib/action_view/context.rb +5 -4
- data/lib/action_view/digestor.rb +7 -6
- data/lib/action_view/gem_version.rb +4 -4
- data/lib/action_view/helpers.rb +0 -2
- data/lib/action_view/helpers/asset_tag_helper.rb +4 -27
- data/lib/action_view/helpers/asset_url_helper.rb +4 -3
- data/lib/action_view/helpers/cache_helper.rb +18 -10
- data/lib/action_view/helpers/capture_helper.rb +4 -0
- data/lib/action_view/helpers/csrf_helper.rb +1 -1
- data/lib/action_view/helpers/date_helper.rb +69 -25
- data/lib/action_view/helpers/form_helper.rb +238 -6
- data/lib/action_view/helpers/form_options_helper.rb +23 -15
- data/lib/action_view/helpers/form_tag_helper.rb +9 -7
- data/lib/action_view/helpers/javascript_helper.rb +9 -8
- data/lib/action_view/helpers/number_helper.rb +5 -0
- data/lib/action_view/helpers/sanitize_helper.rb +3 -3
- data/lib/action_view/helpers/tag_helper.rb +7 -6
- data/lib/action_view/helpers/tags/base.rb +8 -4
- data/lib/action_view/helpers/tags/color_field.rb +1 -1
- data/lib/action_view/helpers/tags/translator.rb +1 -6
- data/lib/action_view/helpers/text_helper.rb +3 -3
- data/lib/action_view/helpers/translation_helper.rb +14 -10
- data/lib/action_view/helpers/url_helper.rb +13 -13
- data/lib/action_view/log_subscriber.rb +6 -6
- data/lib/action_view/lookup_context.rb +4 -4
- data/lib/action_view/railtie.rb +18 -0
- data/lib/action_view/record_identifier.rb +2 -2
- data/lib/action_view/renderer/partial_renderer.rb +2 -2
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +40 -1
- data/lib/action_view/renderer/streaming_template_renderer.rb +1 -1
- data/lib/action_view/rendering.rb +5 -4
- data/lib/action_view/routing_url_for.rb +12 -11
- data/lib/action_view/template.rb +25 -8
- data/lib/action_view/template/handlers/erb.rb +12 -2
- data/lib/action_view/template/resolver.rb +56 -16
- data/lib/action_view/test_case.rb +1 -1
- data/lib/action_view/testing/resolvers.rb +1 -1
- data/lib/assets/compiled/rails-ujs.js +34 -17
- metadata +11 -12
- data/lib/action_view/helpers/record_tag_helper.rb +0 -23
@@ -201,34 +201,42 @@ module ActionView
|
|
201
201
|
end
|
202
202
|
|
203
203
|
# This helper returns the name of a cache key for a given fragment cache
|
204
|
-
# call. By supplying
|
204
|
+
# call. By supplying <tt>skip_digest: true</tt> to cache, the digestion of cache
|
205
205
|
# fragments can be manually bypassed. This is useful when cache fragments
|
206
206
|
# cannot be manually expired unless you know the exact key which is the
|
207
207
|
# case when using memcached.
|
208
208
|
#
|
209
209
|
# The digest will be generated using +virtual_path:+ if it is provided.
|
210
210
|
#
|
211
|
-
def cache_fragment_name(name = {}, skip_digest: nil, virtual_path: nil)
|
211
|
+
def cache_fragment_name(name = {}, skip_digest: nil, virtual_path: nil, digest_path: nil)
|
212
212
|
if skip_digest
|
213
213
|
name
|
214
214
|
else
|
215
|
-
fragment_name_with_digest(name, virtual_path)
|
215
|
+
fragment_name_with_digest(name, virtual_path, digest_path)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def digest_path_from_virtual(virtual_path) # :nodoc:
|
220
|
+
digest = Digestor.digest(name: virtual_path, finder: lookup_context, dependencies: view_cache_dependencies)
|
221
|
+
|
222
|
+
if digest.present?
|
223
|
+
"#{virtual_path}:#{digest}"
|
224
|
+
else
|
225
|
+
virtual_path
|
216
226
|
end
|
217
227
|
end
|
218
228
|
|
219
229
|
private
|
220
230
|
|
221
|
-
def fragment_name_with_digest(name, virtual_path)
|
231
|
+
def fragment_name_with_digest(name, virtual_path, digest_path)
|
222
232
|
virtual_path ||= @virtual_path
|
223
233
|
|
224
|
-
if virtual_path
|
234
|
+
if virtual_path || digest_path
|
225
235
|
name = controller.url_for(name).split("://").last if name.is_a?(Hash)
|
226
236
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
[ virtual_path, name ]
|
231
|
-
end
|
237
|
+
digest_path ||= digest_path_from_virtual(virtual_path)
|
238
|
+
|
239
|
+
[ digest_path, name ]
|
232
240
|
else
|
233
241
|
name
|
234
242
|
end
|
@@ -36,6 +36,10 @@ module ActionView
|
|
36
36
|
# </body>
|
37
37
|
# </html>
|
38
38
|
#
|
39
|
+
# The return of capture is the string generated by the block. For Example:
|
40
|
+
#
|
41
|
+
# @greeting # => "Welcome to my shiny new web page! The date and time is 2018-09-06 11:09:16 -0500"
|
42
|
+
#
|
39
43
|
def capture(*args)
|
40
44
|
value = nil
|
41
45
|
buffer = with_output_buffer { value = yield(*args) }
|
@@ -20,7 +20,7 @@ module ActionView
|
|
20
20
|
# "X-CSRF-Token" HTTP header. If you are using rails-ujs this happens automatically.
|
21
21
|
#
|
22
22
|
def csrf_meta_tags
|
23
|
-
if protect_against_forgery?
|
23
|
+
if defined?(protect_against_forgery?) && protect_against_forgery?
|
24
24
|
[
|
25
25
|
tag("meta", name: "csrf-param", content: request_forgery_protection_token),
|
26
26
|
tag("meta", name: "csrf-token", content: form_authenticity_token)
|
@@ -205,6 +205,7 @@ module ActionView
|
|
205
205
|
# * <tt>:end_year</tt> - Set the end year for the year select. Default is <tt>Date.today.year + 5</tt> if
|
206
206
|
# you are creating new record. While editing existing record, <tt>:end_year</tt> defaults to
|
207
207
|
# the current selected year plus 5.
|
208
|
+
# * <tt>:year_format</tt> - Set format of years for year select. Lambda should be passed.
|
208
209
|
# * <tt>:discard_day</tt> - Set to true if you don't want to show a day select. This includes the day
|
209
210
|
# as a hidden field instead of showing a select field. Also note that this implicitly sets the day to be the
|
210
211
|
# first of the given month in order to not create invalid dates like 31 February.
|
@@ -275,6 +276,9 @@ module ActionView
|
|
275
276
|
# # Generates a date select with custom prompts.
|
276
277
|
# date_select("article", "written_on", prompt: { day: 'Select day', month: 'Select month', year: 'Select year' })
|
277
278
|
#
|
279
|
+
# # Generates a date select with custom year format.
|
280
|
+
# date_select("article", "written_on", year_format: ->(year) { "Heisei #{year - 1988}" })
|
281
|
+
#
|
278
282
|
# The selects are prepared for multi-parameter assignment to an Active Record object.
|
279
283
|
#
|
280
284
|
# Note: If the day is not included as an option but the month is, the day will be set to the 1st to ensure that
|
@@ -302,15 +306,15 @@ module ActionView
|
|
302
306
|
# time_select("article", "start_time", include_seconds: true)
|
303
307
|
#
|
304
308
|
# # You can set the <tt>:minute_step</tt> to 15 which will give you: 00, 15, 30, and 45.
|
305
|
-
# time_select 'game', 'game_time', {minute_step: 15}
|
309
|
+
# time_select 'game', 'game_time', { minute_step: 15 }
|
306
310
|
#
|
307
311
|
# # Creates a time select tag with a custom prompt. Use <tt>prompt: true</tt> for generic prompts.
|
308
|
-
# time_select("article", "written_on", prompt: {hour: 'Choose hour', minute: 'Choose minute', second: 'Choose seconds'})
|
309
|
-
# time_select("article", "written_on", prompt: {hour: true}) # generic prompt for hours
|
312
|
+
# time_select("article", "written_on", prompt: { hour: 'Choose hour', minute: 'Choose minute', second: 'Choose seconds' })
|
313
|
+
# time_select("article", "written_on", prompt: { hour: true }) # generic prompt for hours
|
310
314
|
# time_select("article", "written_on", prompt: true) # generic prompts for all
|
311
315
|
#
|
312
316
|
# # You can set :ampm option to true which will show the hours as: 12 PM, 01 AM .. 11 PM.
|
313
|
-
# time_select 'game', 'game_time', {ampm: true}
|
317
|
+
# time_select 'game', 'game_time', { ampm: true }
|
314
318
|
#
|
315
319
|
# The selects are prepared for multi-parameter assignment to an Active Record object.
|
316
320
|
#
|
@@ -346,8 +350,8 @@ module ActionView
|
|
346
350
|
# datetime_select("article", "written_on", discard_type: true)
|
347
351
|
#
|
348
352
|
# # Generates a datetime select with a custom prompt. Use <tt>prompt: true</tt> for generic prompts.
|
349
|
-
# datetime_select("article", "written_on", prompt: {day: 'Choose day', month: 'Choose month', year: 'Choose year'})
|
350
|
-
# datetime_select("article", "written_on", prompt: {hour: true}) # generic prompt for hours
|
353
|
+
# datetime_select("article", "written_on", prompt: { day: 'Choose day', month: 'Choose month', year: 'Choose year' })
|
354
|
+
# datetime_select("article", "written_on", prompt: { hour: true }) # generic prompt for hours
|
351
355
|
# datetime_select("article", "written_on", prompt: true) # generic prompts for all
|
352
356
|
#
|
353
357
|
# The selects are prepared for multi-parameter assignment to an Active Record object.
|
@@ -397,8 +401,8 @@ module ActionView
|
|
397
401
|
# select_datetime(my_date_time, prefix: 'payday')
|
398
402
|
#
|
399
403
|
# # Generates a datetime select with a custom prompt. Use <tt>prompt: true</tt> for generic prompts.
|
400
|
-
# select_datetime(my_date_time, prompt: {day: 'Choose day', month: 'Choose month', year: 'Choose year'})
|
401
|
-
# select_datetime(my_date_time, prompt: {hour: true}) # generic prompt for hours
|
404
|
+
# select_datetime(my_date_time, prompt: { day: 'Choose day', month: 'Choose month', year: 'Choose year' })
|
405
|
+
# select_datetime(my_date_time, prompt: { hour: true }) # generic prompt for hours
|
402
406
|
# select_datetime(my_date_time, prompt: true) # generic prompts for all
|
403
407
|
def select_datetime(datetime = Time.current, options = {}, html_options = {})
|
404
408
|
DateTimeSelector.new(datetime, options, html_options).select_datetime
|
@@ -436,8 +440,8 @@ module ActionView
|
|
436
440
|
# select_date(my_date, prefix: 'payday')
|
437
441
|
#
|
438
442
|
# # Generates a date select with a custom prompt. Use <tt>prompt: true</tt> for generic prompts.
|
439
|
-
# select_date(my_date, prompt: {day: 'Choose day', month: 'Choose month', year: 'Choose year'})
|
440
|
-
# select_date(my_date, prompt: {hour: true}) # generic prompt for hours
|
443
|
+
# select_date(my_date, prompt: { day: 'Choose day', month: 'Choose month', year: 'Choose year' })
|
444
|
+
# select_date(my_date, prompt: { hour: true }) # generic prompt for hours
|
441
445
|
# select_date(my_date, prompt: true) # generic prompts for all
|
442
446
|
def select_date(date = Date.current, options = {}, html_options = {})
|
443
447
|
DateTimeSelector.new(date, options, html_options).select_date
|
@@ -476,8 +480,8 @@ module ActionView
|
|
476
480
|
# select_time(my_time, start_hour: 2, end_hour: 14)
|
477
481
|
#
|
478
482
|
# # Generates a time select with a custom prompt. Use <tt>:prompt</tt> to true for generic prompts.
|
479
|
-
# select_time(my_time, prompt: {day: 'Choose day', month: 'Choose month', year: 'Choose year'})
|
480
|
-
# select_time(my_time, prompt: {hour: true}) # generic prompt for hours
|
483
|
+
# select_time(my_time, prompt: { day: 'Choose day', month: 'Choose month', year: 'Choose year' })
|
484
|
+
# select_time(my_time, prompt: { hour: true }) # generic prompt for hours
|
481
485
|
# select_time(my_time, prompt: true) # generic prompts for all
|
482
486
|
def select_time(datetime = Time.current, options = {}, html_options = {})
|
483
487
|
DateTimeSelector.new(datetime, options, html_options).select_time
|
@@ -668,8 +672,6 @@ module ActionView
|
|
668
672
|
# <time datetime="2010-11-04T17:55:45+01:00">November 04, 2010 17:55</time>
|
669
673
|
# time_tag Date.yesterday, 'Yesterday' # =>
|
670
674
|
# <time datetime="2010-11-03">Yesterday</time>
|
671
|
-
# time_tag Date.today, pubdate: true # =>
|
672
|
-
# <time datetime="2010-11-04" pubdate="pubdate">November 04, 2010</time>
|
673
675
|
# time_tag Date.today, datetime: Date.today.strftime('%G-W%V') # =>
|
674
676
|
# <time datetime="2010-W44">November 04, 2010</time>
|
675
677
|
#
|
@@ -681,9 +683,8 @@ module ActionView
|
|
681
683
|
options = args.extract_options!
|
682
684
|
format = options.delete(:format) || :long
|
683
685
|
content = args.first || I18n.l(date_or_time, format: format)
|
684
|
-
datetime = date_or_time.acts_like?(:time) ? date_or_time.xmlschema : date_or_time.iso8601
|
685
686
|
|
686
|
-
content_tag("time"
|
687
|
+
content_tag("time", content, options.reverse_merge(datetime: date_or_time.iso8601), &block)
|
687
688
|
end
|
688
689
|
|
689
690
|
private
|
@@ -702,7 +703,7 @@ module ActionView
|
|
702
703
|
class DateTimeSelector #:nodoc:
|
703
704
|
include ActionView::Helpers::TagHelper
|
704
705
|
|
705
|
-
DEFAULT_PREFIX = "date"
|
706
|
+
DEFAULT_PREFIX = "date"
|
706
707
|
POSITION = {
|
707
708
|
year: 1, month: 2, day: 3, hour: 4, minute: 5, second: 6
|
708
709
|
}.freeze
|
@@ -823,7 +824,7 @@ module ActionView
|
|
823
824
|
1.upto(12) do |month_number|
|
824
825
|
options = { value: month_number }
|
825
826
|
options[:selected] = "selected" if month == month_number
|
826
|
-
month_options << content_tag("option"
|
827
|
+
month_options << content_tag("option", month_name(month_number), options) + "\n"
|
827
828
|
end
|
828
829
|
build_select(:month, month_options.join)
|
829
830
|
end
|
@@ -851,7 +852,7 @@ module ActionView
|
|
851
852
|
raise ArgumentError, "There are too many years options to be built. Are you sure you haven't mistyped something? You can provide the :max_years_allowed parameter."
|
852
853
|
end
|
853
854
|
|
854
|
-
|
855
|
+
build_select(:year, build_year_options(val, options))
|
855
856
|
end
|
856
857
|
end
|
857
858
|
|
@@ -934,6 +935,21 @@ module ActionView
|
|
934
935
|
end
|
935
936
|
end
|
936
937
|
|
938
|
+
# Looks up year names by number.
|
939
|
+
#
|
940
|
+
# year_name(1998) # => 1998
|
941
|
+
#
|
942
|
+
# If the <tt>:year_format</tt> option is passed:
|
943
|
+
#
|
944
|
+
# year_name(1998) # => "Heisei 10"
|
945
|
+
def year_name(number)
|
946
|
+
if year_format_lambda = @options[:year_format]
|
947
|
+
year_format_lambda.call(number)
|
948
|
+
else
|
949
|
+
number
|
950
|
+
end
|
951
|
+
end
|
952
|
+
|
937
953
|
def date_order
|
938
954
|
@date_order ||= @options[:order] || translated_date_order
|
939
955
|
end
|
@@ -990,7 +1006,35 @@ module ActionView
|
|
990
1006
|
tag_options[:selected] = "selected" if selected == i
|
991
1007
|
text = options[:use_two_digit_numbers] ? sprintf("%02d", i) : value
|
992
1008
|
text = options[:ampm] ? AMPM_TRANSLATION[i] : text
|
993
|
-
select_options << content_tag("option"
|
1009
|
+
select_options << content_tag("option", text, tag_options)
|
1010
|
+
end
|
1011
|
+
|
1012
|
+
(select_options.join("\n") + "\n").html_safe
|
1013
|
+
end
|
1014
|
+
|
1015
|
+
# Build select option HTML for year.
|
1016
|
+
# If <tt>year_format</tt> option is not passed
|
1017
|
+
# build_year_options(1998, start: 1998, end: 2000)
|
1018
|
+
# => "<option value="1998" selected="selected">1998</option>
|
1019
|
+
# <option value="1999">1999</option>
|
1020
|
+
# <option value="2000">2000</option>"
|
1021
|
+
#
|
1022
|
+
# If <tt>year_format</tt> option is passed
|
1023
|
+
# build_year_options(1998, start: 1998, end: 2000, year_format: ->year { "Heisei #{ year - 1988 }" })
|
1024
|
+
# => "<option value="1998" selected="selected">Heisei 10</option>
|
1025
|
+
# <option value="1999">Heisei 11</option>
|
1026
|
+
# <option value="2000">Heisei 12</option>"
|
1027
|
+
def build_year_options(selected, options = {})
|
1028
|
+
start = options.delete(:start)
|
1029
|
+
stop = options.delete(:end)
|
1030
|
+
step = options.delete(:step)
|
1031
|
+
|
1032
|
+
select_options = []
|
1033
|
+
start.step(stop, step) do |value|
|
1034
|
+
tag_options = { value: value }
|
1035
|
+
tag_options[:selected] = "selected" if selected == value
|
1036
|
+
text = year_name(value)
|
1037
|
+
select_options << content_tag("option", text, tag_options)
|
994
1038
|
end
|
995
1039
|
|
996
1040
|
(select_options.join("\n") + "\n").html_safe
|
@@ -1009,12 +1053,12 @@ module ActionView
|
|
1009
1053
|
select_options[:disabled] = "disabled" if @options[:disabled]
|
1010
1054
|
select_options[:class] = css_class_attribute(type, select_options[:class], @options[:with_css_classes]) if @options[:with_css_classes]
|
1011
1055
|
|
1012
|
-
select_html = "\n"
|
1013
|
-
select_html << content_tag("option"
|
1056
|
+
select_html = +"\n"
|
1057
|
+
select_html << content_tag("option", "", value: "") + "\n" if @options[:include_blank]
|
1014
1058
|
select_html << prompt_option_tag(type, @options[:prompt]) + "\n" if @options[:prompt]
|
1015
1059
|
select_html << select_options_as_html
|
1016
1060
|
|
1017
|
-
(content_tag("select"
|
1061
|
+
(content_tag("select", select_html.html_safe, select_options) + "\n").html_safe
|
1018
1062
|
end
|
1019
1063
|
|
1020
1064
|
# Builds the css class value for the select element
|
@@ -1047,7 +1091,7 @@ module ActionView
|
|
1047
1091
|
I18n.translate(:"datetime.prompts.#{type}", locale: @options[:locale])
|
1048
1092
|
end
|
1049
1093
|
|
1050
|
-
prompt ? content_tag("option"
|
1094
|
+
prompt ? content_tag("option", prompt, value: "") : ""
|
1051
1095
|
end
|
1052
1096
|
|
1053
1097
|
# Builds hidden input tag for date part and value.
|
@@ -1091,7 +1135,7 @@ module ActionView
|
|
1091
1135
|
# Given an ordering of datetime components, create the selection HTML
|
1092
1136
|
# and join them with their appropriate separators.
|
1093
1137
|
def build_selects_from_types(order)
|
1094
|
-
select = ""
|
1138
|
+
select = +""
|
1095
1139
|
first_visible = order.find { |type| !@options[:"discard_#{type}"] }
|
1096
1140
|
order.reverse_each do |type|
|
1097
1141
|
separator = separator(type) unless type == first_visible # don't add before first visible field
|
@@ -590,6 +590,9 @@ module ActionView
|
|
590
590
|
# Skipped if a <tt>:url</tt> is passed.
|
591
591
|
# * <tt>:scope</tt> - The scope to prefix input field names with and
|
592
592
|
# thereby how the submitted parameters are grouped in controllers.
|
593
|
+
# * <tt>:namespace</tt> - A namespace for your form to ensure uniqueness of
|
594
|
+
# id attributes on form elements. The namespace attribute will be prefixed
|
595
|
+
# with underscore on the generated HTML id.
|
593
596
|
# * <tt>:model</tt> - A model object to infer the <tt>:url</tt> and
|
594
597
|
# <tt>:scope</tt> by, plus fill out input field values.
|
595
598
|
# So if a +title+ attribute is set to "Ahoy!" then a +title+ input
|
@@ -610,8 +613,8 @@ module ActionView
|
|
610
613
|
# unnecessary unless you support browsers without JavaScript.
|
611
614
|
# * <tt>:local</tt> - By default form submits are remote and unobtrusive XHRs.
|
612
615
|
# Disable remote submits with <tt>local: true</tt>.
|
613
|
-
# * <tt>:skip_enforcing_utf8</tt> -
|
614
|
-
# is output
|
616
|
+
# * <tt>:skip_enforcing_utf8</tt> - If set to true, a hidden input with name
|
617
|
+
# utf8 is not output.
|
615
618
|
# * <tt>:builder</tt> - Override the object used to build the form.
|
616
619
|
# * <tt>:id</tt> - Optional HTML id attribute.
|
617
620
|
# * <tt>:class</tt> - Optional HTML class attribute.
|
@@ -1127,6 +1130,9 @@ module ActionView
|
|
1127
1130
|
# text_field(:post, :title, class: "create_input")
|
1128
1131
|
# # => <input type="text" id="post_title" name="post[title]" value="#{@post.title}" class="create_input" />
|
1129
1132
|
#
|
1133
|
+
# text_field(:post, :title, maxlength: 30, class: "title_input")
|
1134
|
+
# # => <input type="text" id="post_title" name="post[title]" maxlength="30" size="30" value="#{@post.title}" class="title_input" />
|
1135
|
+
#
|
1130
1136
|
# text_field(:session, :user, onchange: "if ($('#session_user').val() === 'admin') { alert('Your login cannot be admin!'); }")
|
1131
1137
|
# # => <input type="text" id="session_user" name="session[user]" value="#{@session.user}" onchange="if ($('#session_user').val() === 'admin') { alert('Your login cannot be admin!'); }"/>
|
1132
1138
|
#
|
@@ -1519,10 +1525,10 @@ module ActionView
|
|
1519
1525
|
|
1520
1526
|
private
|
1521
1527
|
def html_options_for_form_with(url_for_options = nil, model = nil, html: {}, local: !form_with_generates_remote_forms,
|
1522
|
-
skip_enforcing_utf8:
|
1528
|
+
skip_enforcing_utf8: nil, **options)
|
1523
1529
|
html_options = options.slice(:id, :class, :multipart, :method, :data).merge(html)
|
1524
1530
|
html_options[:method] ||= :patch if model.respond_to?(:persisted?) && model.persisted?
|
1525
|
-
html_options[:enforce_utf8] = !skip_enforcing_utf8
|
1531
|
+
html_options[:enforce_utf8] = !skip_enforcing_utf8 unless skip_enforcing_utf8.nil?
|
1526
1532
|
|
1527
1533
|
html_options[:enctype] = "multipart/form-data" if html_options.delete(:multipart)
|
1528
1534
|
|
@@ -1674,6 +1680,227 @@ module ActionView
|
|
1674
1680
|
@index = options[:index] || options[:child_index]
|
1675
1681
|
end
|
1676
1682
|
|
1683
|
+
##
|
1684
|
+
# :method: text_field
|
1685
|
+
#
|
1686
|
+
# :call-seq: text_field(method, options = {})
|
1687
|
+
#
|
1688
|
+
# Wraps ActionView::Helpers::FormHelper#text_field for form builders:
|
1689
|
+
#
|
1690
|
+
# <%= form_with model: @user do |f| %>
|
1691
|
+
# <%= f.text_field :name %>
|
1692
|
+
# <% end %>
|
1693
|
+
#
|
1694
|
+
# Please refer to the documentation of the base helper for details.
|
1695
|
+
|
1696
|
+
##
|
1697
|
+
# :method: password_field
|
1698
|
+
#
|
1699
|
+
# :call-seq: password_field(method, options = {})
|
1700
|
+
#
|
1701
|
+
# Wraps ActionView::Helpers::FormHelper#password_field for form builders:
|
1702
|
+
#
|
1703
|
+
# <%= form_with model: @user do |f| %>
|
1704
|
+
# <%= f.password_field :password %>
|
1705
|
+
# <% end %>
|
1706
|
+
#
|
1707
|
+
# Please refer to the documentation of the base helper for details.
|
1708
|
+
|
1709
|
+
##
|
1710
|
+
# :method: text_area
|
1711
|
+
#
|
1712
|
+
# :call-seq: text_area(method, options = {})
|
1713
|
+
#
|
1714
|
+
# Wraps ActionView::Helpers::FormHelper#text_area for form builders:
|
1715
|
+
#
|
1716
|
+
# <%= form_with model: @user do |f| %>
|
1717
|
+
# <%= f.text_area :detail %>
|
1718
|
+
# <% end %>
|
1719
|
+
#
|
1720
|
+
# Please refer to the documentation of the base helper for details.
|
1721
|
+
|
1722
|
+
##
|
1723
|
+
# :method: color_field
|
1724
|
+
#
|
1725
|
+
# :call-seq: color_field(method, options = {})
|
1726
|
+
#
|
1727
|
+
# Wraps ActionView::Helpers::FormHelper#color_field for form builders:
|
1728
|
+
#
|
1729
|
+
# <%= form_with model: @user do |f| %>
|
1730
|
+
# <%= f.color_field :favorite_color %>
|
1731
|
+
# <% end %>
|
1732
|
+
#
|
1733
|
+
# Please refer to the documentation of the base helper for details.
|
1734
|
+
|
1735
|
+
##
|
1736
|
+
# :method: search_field
|
1737
|
+
#
|
1738
|
+
# :call-seq: search_field(method, options = {})
|
1739
|
+
#
|
1740
|
+
# Wraps ActionView::Helpers::FormHelper#search_field for form builders:
|
1741
|
+
#
|
1742
|
+
# <%= form_with model: @user do |f| %>
|
1743
|
+
# <%= f.search_field :name %>
|
1744
|
+
# <% end %>
|
1745
|
+
#
|
1746
|
+
# Please refer to the documentation of the base helper for details.
|
1747
|
+
|
1748
|
+
##
|
1749
|
+
# :method: telephone_field
|
1750
|
+
#
|
1751
|
+
# :call-seq: telephone_field(method, options = {})
|
1752
|
+
#
|
1753
|
+
# Wraps ActionView::Helpers::FormHelper#telephone_field for form builders:
|
1754
|
+
#
|
1755
|
+
# <%= form_with model: @user do |f| %>
|
1756
|
+
# <%= f.telephone_field :phone %>
|
1757
|
+
# <% end %>
|
1758
|
+
#
|
1759
|
+
# Please refer to the documentation of the base helper for details.
|
1760
|
+
|
1761
|
+
##
|
1762
|
+
# :method: phone_field
|
1763
|
+
#
|
1764
|
+
# :call-seq: phone_field(method, options = {})
|
1765
|
+
#
|
1766
|
+
# Wraps ActionView::Helpers::FormHelper#phone_field for form builders:
|
1767
|
+
#
|
1768
|
+
# <%= form_with model: @user do |f| %>
|
1769
|
+
# <%= f.phone_field :phone %>
|
1770
|
+
# <% end %>
|
1771
|
+
#
|
1772
|
+
# Please refer to the documentation of the base helper for details.
|
1773
|
+
|
1774
|
+
##
|
1775
|
+
# :method: date_field
|
1776
|
+
#
|
1777
|
+
# :call-seq: date_field(method, options = {})
|
1778
|
+
#
|
1779
|
+
# Wraps ActionView::Helpers::FormHelper#date_field for form builders:
|
1780
|
+
#
|
1781
|
+
# <%= form_with model: @user do |f| %>
|
1782
|
+
# <%= f.date_field :born_on %>
|
1783
|
+
# <% end %>
|
1784
|
+
#
|
1785
|
+
# Please refer to the documentation of the base helper for details.
|
1786
|
+
|
1787
|
+
##
|
1788
|
+
# :method: time_field
|
1789
|
+
#
|
1790
|
+
# :call-seq: time_field(method, options = {})
|
1791
|
+
#
|
1792
|
+
# Wraps ActionView::Helpers::FormHelper#time_field for form builders:
|
1793
|
+
#
|
1794
|
+
# <%= form_with model: @user do |f| %>
|
1795
|
+
# <%= f.time_field :borned_at %>
|
1796
|
+
# <% end %>
|
1797
|
+
#
|
1798
|
+
# Please refer to the documentation of the base helper for details.
|
1799
|
+
|
1800
|
+
##
|
1801
|
+
# :method: datetime_field
|
1802
|
+
#
|
1803
|
+
# :call-seq: datetime_field(method, options = {})
|
1804
|
+
#
|
1805
|
+
# Wraps ActionView::Helpers::FormHelper#datetime_field for form builders:
|
1806
|
+
#
|
1807
|
+
# <%= form_with model: @user do |f| %>
|
1808
|
+
# <%= f.datetime_field :graduation_day %>
|
1809
|
+
# <% end %>
|
1810
|
+
#
|
1811
|
+
# Please refer to the documentation of the base helper for details.
|
1812
|
+
|
1813
|
+
##
|
1814
|
+
# :method: datetime_local_field
|
1815
|
+
#
|
1816
|
+
# :call-seq: datetime_local_field(method, options = {})
|
1817
|
+
#
|
1818
|
+
# Wraps ActionView::Helpers::FormHelper#datetime_local_field for form builders:
|
1819
|
+
#
|
1820
|
+
# <%= form_with model: @user do |f| %>
|
1821
|
+
# <%= f.datetime_local_field :graduation_day %>
|
1822
|
+
# <% end %>
|
1823
|
+
#
|
1824
|
+
# Please refer to the documentation of the base helper for details.
|
1825
|
+
|
1826
|
+
##
|
1827
|
+
# :method: month_field
|
1828
|
+
#
|
1829
|
+
# :call-seq: month_field(method, options = {})
|
1830
|
+
#
|
1831
|
+
# Wraps ActionView::Helpers::FormHelper#month_field for form builders:
|
1832
|
+
#
|
1833
|
+
# <%= form_with model: @user do |f| %>
|
1834
|
+
# <%= f.month_field :birthday_month %>
|
1835
|
+
# <% end %>
|
1836
|
+
#
|
1837
|
+
# Please refer to the documentation of the base helper for details.
|
1838
|
+
|
1839
|
+
##
|
1840
|
+
# :method: week_field
|
1841
|
+
#
|
1842
|
+
# :call-seq: week_field(method, options = {})
|
1843
|
+
#
|
1844
|
+
# Wraps ActionView::Helpers::FormHelper#week_field for form builders:
|
1845
|
+
#
|
1846
|
+
# <%= form_with model: @user do |f| %>
|
1847
|
+
# <%= f.week_field :birthday_week %>
|
1848
|
+
# <% end %>
|
1849
|
+
#
|
1850
|
+
# Please refer to the documentation of the base helper for details.
|
1851
|
+
|
1852
|
+
##
|
1853
|
+
# :method: url_field
|
1854
|
+
#
|
1855
|
+
# :call-seq: url_field(method, options = {})
|
1856
|
+
#
|
1857
|
+
# Wraps ActionView::Helpers::FormHelper#url_field for form builders:
|
1858
|
+
#
|
1859
|
+
# <%= form_with model: @user do |f| %>
|
1860
|
+
# <%= f.url_field :homepage %>
|
1861
|
+
# <% end %>
|
1862
|
+
#
|
1863
|
+
# Please refer to the documentation of the base helper for details.
|
1864
|
+
|
1865
|
+
##
|
1866
|
+
# :method: email_field
|
1867
|
+
#
|
1868
|
+
# :call-seq: email_field(method, options = {})
|
1869
|
+
#
|
1870
|
+
# Wraps ActionView::Helpers::FormHelper#email_field for form builders:
|
1871
|
+
#
|
1872
|
+
# <%= form_with model: @user do |f| %>
|
1873
|
+
# <%= f.email_field :address %>
|
1874
|
+
# <% end %>
|
1875
|
+
#
|
1876
|
+
# Please refer to the documentation of the base helper for details.
|
1877
|
+
|
1878
|
+
##
|
1879
|
+
# :method: number_field
|
1880
|
+
#
|
1881
|
+
# :call-seq: number_field(method, options = {})
|
1882
|
+
#
|
1883
|
+
# Wraps ActionView::Helpers::FormHelper#number_field for form builders:
|
1884
|
+
#
|
1885
|
+
# <%= form_with model: @user do |f| %>
|
1886
|
+
# <%= f.number_field :age %>
|
1887
|
+
# <% end %>
|
1888
|
+
#
|
1889
|
+
# Please refer to the documentation of the base helper for details.
|
1890
|
+
|
1891
|
+
##
|
1892
|
+
# :method: range_field
|
1893
|
+
#
|
1894
|
+
# :call-seq: range_field(method, options = {})
|
1895
|
+
#
|
1896
|
+
# Wraps ActionView::Helpers::FormHelper#range_field for form builders:
|
1897
|
+
#
|
1898
|
+
# <%= form_with model: @user do |f| %>
|
1899
|
+
# <%= f.range_field :age %>
|
1900
|
+
# <% end %>
|
1901
|
+
#
|
1902
|
+
# Please refer to the documentation of the base helper for details.
|
1903
|
+
|
1677
1904
|
(field_helpers - [:label, :check_box, :radio_button, :fields_for, :fields, :hidden_field, :file_field]).each do |selector|
|
1678
1905
|
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
|
1679
1906
|
def #{selector}(method, options = {}) # def text_field(method, options = {})
|
@@ -2247,7 +2474,7 @@ module ActionView
|
|
2247
2474
|
@template.button_tag(value, options, &block)
|
2248
2475
|
end
|
2249
2476
|
|
2250
|
-
def emitted_hidden_id?
|
2477
|
+
def emitted_hidden_id? # :nodoc:
|
2251
2478
|
@emitted_hidden_id ||= nil
|
2252
2479
|
end
|
2253
2480
|
|
@@ -2267,7 +2494,12 @@ module ActionView
|
|
2267
2494
|
end
|
2268
2495
|
|
2269
2496
|
defaults = []
|
2270
|
-
|
2497
|
+
# Object is a model and it is not overwritten by as and scope option.
|
2498
|
+
if object.respond_to?(:model_name) && object_name.to_s == model.downcase
|
2499
|
+
defaults << :"helpers.submit.#{object.model_name.i18n_key}.#{key}"
|
2500
|
+
else
|
2501
|
+
defaults << :"helpers.submit.#{object_name}.#{key}"
|
2502
|
+
end
|
2271
2503
|
defaults << :"helpers.submit.#{key}"
|
2272
2504
|
defaults << "#{key.to_s.humanize} #{model}"
|
2273
2505
|
|