aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2015-12-31 00:40:33 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2015-12-31 00:40:37 -0300
commit7e583b73c4e7ddad2241b2ca05b3c16a5fdf0cc6 (patch)
treec8d4aef0089a3098507ad34ac5ff3452e4eadf9a /actionview/lib/action_view/helpers
parentb238dd73410bafe2b710cd33b74c54263ba85171 (diff)
downloadrails-7e583b73c4e7ddad2241b2ca05b3c16a5fdf0cc6.tar.gz
rails-7e583b73c4e7ddad2241b2ca05b3c16a5fdf0cc6.tar.bz2
rails-7e583b73c4e7ddad2241b2ca05b3c16a5fdf0cc6.zip
Fix collection_radio_buttons' hidden_field name and make it appear before the radios
Fixes #22773
Diffstat (limited to 'actionview/lib/action_view/helpers')
-rw-r--r--actionview/lib/action_view/helpers/tags/collection_check_boxes.rb4
-rw-r--r--actionview/lib/action_view/helpers/tags/collection_helpers.rb8
2 files changed, 10 insertions, 2 deletions
diff --git a/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb b/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb
index 3256d44e18..3dda47a458 100644
--- a/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb
+++ b/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb
@@ -23,6 +23,10 @@ module ActionView
def render_component(builder)
builder.check_box + builder.label
end
+
+ def hidden_field_name #:nodoc:
+ "#{super}[]"
+ end
end
end
end
diff --git a/actionview/lib/action_view/helpers/tags/collection_helpers.rb b/actionview/lib/action_view/helpers/tags/collection_helpers.rb
index b87b4281d6..1d3b1ecf0b 100644
--- a/actionview/lib/action_view/helpers/tags/collection_helpers.rb
+++ b/actionview/lib/action_view/helpers/tags/collection_helpers.rb
@@ -97,16 +97,20 @@ module ActionView
# Append a hidden field to make sure something will be sent back to the
# server if all radio buttons are unchecked.
if options.fetch('include_hidden', true)
- rendered_collection + hidden_field
+ hidden_field + rendered_collection
else
rendered_collection
end
end
def hidden_field #:nodoc:
- hidden_name = @html_options[:name] || "#{tag_name(false, @options[:index])}[]"
+ hidden_name = @html_options[:name] || hidden_field_name
@template_object.hidden_field_tag(hidden_name, "", id: nil)
end
+
+ def hidden_field_name #:nodoc:
+ "#{tag_name(false, @options[:index])}"
+ end
end
end
end