diff --git a/CHANGELOG.md b/CHANGELOG.md index 83b9ebea7..9ed6f469d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ Bugfixes: Features: - Your contribution here! + * [#325](https://github.com/bootstrap-ruby/rails-bootstrap-forms/pull/325): Support :prepend and :append for the `select` helper - [@donv](https://github.com/donv). + ## [2.6.0][] (2017-02-03) diff --git a/lib/bootstrap_form/form_builder.rb b/lib/bootstrap_form/form_builder.rb index 91a4e7ae7..423360e6e 100644 --- a/lib/bootstrap_form/form_builder.rb +++ b/lib/bootstrap_form/form_builder.rb @@ -71,13 +71,17 @@ def file_field_with_bootstrap(name, options = {}) if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new("4.1.0") def select_with_bootstrap(method, choices = nil, options = {}, html_options = {}, &block) form_group_builder(method, options, html_options) do - select_without_bootstrap(method, choices, options, html_options, &block) + prepend_and_append_input(options) do + select_without_bootstrap(method, choices, options, html_options, &block) + end end end else def select_with_bootstrap(method, choices, options = {}, html_options = {}) form_group_builder(method, options, html_options) do - select_without_bootstrap(method, choices, options, html_options) + prepend_and_append_input(options) do + select_without_bootstrap(method, choices, options, html_options) + end end end end diff --git a/test/bootstrap_selects_test.rb b/test/bootstrap_selects_test.rb index 310126aae..f934fdd4b 100644 --- a/test/bootstrap_selects_test.rb +++ b/test/bootstrap_selects_test.rb @@ -32,6 +32,23 @@ def setup assert_equivalent_xml expected, @builder.select(:status, [['activated', 1], ['blocked', 2]], { prompt: "Please Select" }, class: "my-select") end + test 'selects with addons are wrapped correctly' do + expected = <<-HTML.strip_heredoc +