diff --git a/demo/test/system/bootstrap_test.rb b/demo/test/system/bootstrap_test.rb index e08b961f5..000179246 100644 --- a/demo/test/system/bootstrap_test.rb +++ b/demo/test/system/bootstrap_test.rb @@ -71,7 +71,7 @@ class BootstrapTest < ApplicationSystemTestCase #{html} MD end - augmented_readme.gsub!(/127.0.0.1:\d+/,'test.host') + augmented_readme.gsub!(/127.0.0.1:\d+/, "test.host") File.write(File.expand_path("../../../README.md", __dir__), augmented_readme) end diff --git a/lib/bootstrap_form/inputs/collection_select.rb b/lib/bootstrap_form/inputs/collection_select.rb index 74f7ffd81..c43091ebc 100644 --- a/lib/bootstrap_form/inputs/collection_select.rb +++ b/lib/bootstrap_form/inputs/collection_select.rb @@ -12,7 +12,7 @@ module CollectionSelect def collection_select_with_bootstrap(method, collection, value_method, text_method, options={}, html_options={}) html_options = html_options.reverse_merge(control_class: "form-select") form_group_builder(method, options, html_options) do - input_with_error(method) do + prepend_and_append_input(method, options) do collection_select_without_bootstrap(method, collection, value_method, text_method, options, html_options) end end diff --git a/lib/bootstrap_form/inputs/grouped_collection_select.rb b/lib/bootstrap_form/inputs/grouped_collection_select.rb index a62a9b864..ab80d8417 100644 --- a/lib/bootstrap_form/inputs/grouped_collection_select.rb +++ b/lib/bootstrap_form/inputs/grouped_collection_select.rb @@ -14,7 +14,7 @@ def grouped_collection_select_with_bootstrap(method, collection, group_method, option_value_method, options={}, html_options={}) html_options = html_options.reverse_merge(control_class: "form-select") form_group_builder(method, options, html_options) do - input_with_error(method) do + prepend_and_append_input(method, options) do grouped_collection_select_without_bootstrap(method, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options) diff --git a/test/bootstrap_selects_test.rb b/test/bootstrap_selects_test.rb index 1ecb5f777..5d43fd809 100644 --- a/test/bootstrap_selects_test.rb +++ b/test/bootstrap_selects_test.rb @@ -229,6 +229,24 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) @builder.collection_select(:status, [], :id, :name, { prompt: "Please Select" }, class: "my-select") end + test "collection_selects with addons are wrapped correctly" do + expected = <<~HTML +
+ +
+ Before + + After +
+
+ HTML + assert_equivalent_xml expected, + @builder.collection_select(:status, [], :id, :name, + { prepend: "Before", append: "After", prompt: "Please Select" }) + end + test "grouped_collection_selects are wrapped correctly" do expected = <<~HTML
@@ -293,6 +311,24 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) class: "my-select") end + test "grouped_collection_selects with addons are wrapped correctly" do + expected = <<~HTML +
+ +
+ Before + + After +
+
+ HTML + assert_equivalent_xml expected, + @builder.grouped_collection_select(:status, [], :last, :first, :to_s, :to_s, + { prepend: "Before", append: "After", prompt: "Please Select" }) + end + test "date selects are wrapped correctly" do travel_to(Time.utc(2012, 2, 3)) do expected = <<~HTML