diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md
index 122c42c5bd..ceaea40d18 100644
--- a/actionview/CHANGELOG.md
+++ b/actionview/CHANGELOG.md
@@ -1,3 +1,11 @@
+* Generate field ids in `collection_check_boxes` and `collection_radio_buttons`.
+
+ This makes sure that the labels are linked up with the fields.
+
+ Fixes #29014.
+
+ *Yuji Yaginuma*
+
* Add `:json` type to `auto_discovery_link_tag` to support [JSON Feeds](https://jsonfeed.org/version/1)
*Mike Gunderloy*
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 7252d4f2d9..e02b7bdb2e 100644
--- a/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb
+++ b/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb
@@ -10,6 +10,7 @@ module ActionView
def check_box(extra_html_options = {})
html_options = extra_html_options.merge(@input_html_options)
html_options[:multiple] = true
+ html_options[:skip_default_ids] = false
@template_object.check_box(@object_name, @method_name, html_options, @value, nil)
end
end
diff --git a/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb b/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb
index a5f72af9ff..f085a5fb73 100644
--- a/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb
+++ b/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb
@@ -9,6 +9,7 @@ module ActionView
class RadioButtonBuilder < Builder # :nodoc:
def radio_button(extra_html_options = {})
html_options = extra_html_options.merge(@input_html_options)
+ html_options[:skip_default_ids] = false
@template_object.radio_button(@object_name, @method_name, @value, html_options)
end
end
diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb
index df580f0369..ecdd5ce672 100644
--- a/actionview/test/template/form_helper/form_with_test.rb
+++ b/actionview/test/template/form_helper/form_with_test.rb
@@ -403,9 +403,9 @@ class FormWithActsLikeFormForTest < FormWithTest
expected = whole_form("/posts") do
"" \
- "" \
+ "" \
"" \
- "" \
+ "" \
""
end
@@ -426,10 +426,10 @@ class FormWithActsLikeFormForTest < FormWithTest
expected = whole_form("/posts") do
"" \
"" \
""
end
@@ -452,10 +452,10 @@ class FormWithActsLikeFormForTest < FormWithTest
expected = whole_form("/posts") do
"" \
"" \
"" \
""
end
@@ -473,9 +473,9 @@ class FormWithActsLikeFormForTest < FormWithTest
expected = whole_form("/posts") do
"" \
- "" \
+ "" \
"" \
- "" \
+ "" \
""
end
@@ -492,11 +492,11 @@ class FormWithActsLikeFormForTest < FormWithTest
expected = whole_form("/posts") do
"" \
- "" \
+ "" \
"" \
- "" \
+ "" \
"" \
- "" \
+ "" \
""
end
@@ -517,13 +517,13 @@ class FormWithActsLikeFormForTest < FormWithTest
expected = whole_form("/posts") do
"" \
"" \
"" \
""
end
@@ -547,13 +547,13 @@ class FormWithActsLikeFormForTest < FormWithTest
expected = whole_form("/posts") do
"" \
"" \
"" \
"" \
""
end
@@ -572,7 +572,7 @@ class FormWithActsLikeFormForTest < FormWithTest
expected = whole_form("/posts") do
"" \
- "" \
+ "" \
""
end