diff options
Diffstat (limited to 'actionview/lib/action_view/helpers/tags/collection_helpers.rb')
-rw-r--r-- | actionview/lib/action_view/helpers/tags/collection_helpers.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/actionview/lib/action_view/helpers/tags/collection_helpers.rb b/actionview/lib/action_view/helpers/tags/collection_helpers.rb index 36575b2fd0..e1ad11bff8 100644 --- a/actionview/lib/action_view/helpers/tags/collection_helpers.rb +++ b/actionview/lib/action_view/helpers/tags/collection_helpers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ActionView module Helpers module Tags # :nodoc: @@ -17,7 +19,7 @@ module ActionView @input_html_options = input_html_options end - def label(label_html_options={}, &block) + def label(label_html_options = {}, &block) html_options = @input_html_options.slice(:index, :namespace).merge(label_html_options) html_options[:for] ||= @input_html_options[:id] if @input_html_options[:id] @@ -43,7 +45,7 @@ module ActionView # Generate default options for collection helpers, such as :checked and # :disabled. - def default_html_options_for_collection(item, value) #:nodoc: + def default_html_options_for_collection(item, value) html_options = @html_options.dup [:checked, :selected, :disabled, :readonly].each do |option| @@ -67,11 +69,11 @@ module ActionView html_options end - def sanitize_attribute_name(value) #:nodoc: + def sanitize_attribute_name(value) "#{sanitized_method_name}_#{sanitized_value(value)}" end - def render_collection #:nodoc: + def render_collection @collection.map do |item| value = value_for_collection(item, @value_method) text = value_for_collection(item, @text_method) @@ -82,7 +84,7 @@ module ActionView end.join.html_safe end - def render_collection_for(builder_class, &block) #:nodoc: + def render_collection_for(builder_class, &block) options = @options.stringify_keys rendered_collection = render_collection do |item, value, text, default_html_options| builder = instantiate_builder(builder_class, item, value, text, default_html_options) @@ -103,12 +105,12 @@ module ActionView end end - def hidden_field #:nodoc: + def hidden_field hidden_name = @html_options[:name] || hidden_field_name @template_object.hidden_field_tag(hidden_name, "", id: nil) end - def hidden_field_name #:nodoc: + def hidden_field_name "#{tag_name(false, @options[:index])}" end end |