From d2e6aa24d44fdb194fa386aead2ce9b1661211d1 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Tue, 30 Jun 2026 09:10:01 +1200 Subject: [PATCH 1/5] fix: make alert message focusable for accessibility --- lib/bootstrap_form/helpers/bootstrap.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bootstrap_form/helpers/bootstrap.rb b/lib/bootstrap_form/helpers/bootstrap.rb index 1cf39ce4..f83893c8 100644 --- a/lib/bootstrap_form/helpers/bootstrap.rb +++ b/lib/bootstrap_form/helpers/bootstrap.rb @@ -9,7 +9,7 @@ def alert_message(title, options={}) css = options[:class] || "alert alert-danger" return unless object.respond_to?(:errors) && object.errors.full_messages.any? - tag.div class: css do + tag.div class: css, tabindex: "-1" do if options[:error_summary] == false title else From 40cf5dfb541f816fd921c74729724d85abd293f1 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Tue, 29 Sep 2026 15:21:49 +1300 Subject: [PATCH 2/5] feat: pass extra `alert_message` keywords to `div` --- lib/bootstrap_form/helpers/bootstrap.rb | 2 +- test/bootstrap_form_test.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/bootstrap_form/helpers/bootstrap.rb b/lib/bootstrap_form/helpers/bootstrap.rb index f83893c8..7f3d7d3f 100644 --- a/lib/bootstrap_form/helpers/bootstrap.rb +++ b/lib/bootstrap_form/helpers/bootstrap.rb @@ -9,7 +9,7 @@ def alert_message(title, options={}) css = options[:class] || "alert alert-danger" return unless object.respond_to?(:errors) && object.errors.full_messages.any? - tag.div class: css, tabindex: "-1" do + tag.div class: css, **options.except(:class, :error_summary) do if options[:error_summary] == false title else diff --git a/test/bootstrap_form_test.rb b/test/bootstrap_form_test.rb index 33d04f23..979d9bd1 100644 --- a/test/bootstrap_form_test.rb +++ b/test/bootstrap_form_test.rb @@ -593,6 +593,23 @@ def warn(message, ...) assert_equivalent_html expected, @builder.alert_message("Please fix the following errors:", class: "my-css-class") end + test "alert_message passes extra options through as HTML attributes" do + @user.email = nil + assert @user.invalid? + + expected = <<~HTML +
+

Please fix the following errors:

+ +
+ HTML + assert_equivalent_html expected, @builder.alert_message("Please fix the following errors:", tabindex: "-1", role: "note") + end + test "alert_message contains the error summary when inline_errors are turned off" do @user.email = nil assert @user.invalid? From ee4b5356f73686324c26aecf0559c6dcaf14156c Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Thu, 1 Oct 2026 13:28:35 +1300 Subject: [PATCH 3/5] docs: add section to readme --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 6bd40fda..957c0d51 100644 --- a/README.md +++ b/README.md @@ -1614,6 +1614,29 @@ This generates: ``` +Additional options will be passed on as attributes to the root `div`: + +```erb +<%= bootstrap_form_for @user_with_error do |f| %> + <%= f.alert_message "Please fix the errors below.", tabindex: -1, role: "note" %> +<% end %> +``` + +This generates: + +```html +
+
+

Please fix the errors below.

+ +
+
+``` + To output a simple unordered list of errors, use the `error_summary` helper. ![Example 51](demo/doc/screenshots/bootstrap/readme/51_example.png "Example 51") From 5995353483003d2b142abd8902c92e7e9c1231d3 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Fri, 2 Oct 2026 15:39:52 +1300 Subject: [PATCH 4/5] docs: use existing example --- README.md | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 957c0d51..5d868003 100644 --- a/README.md +++ b/README.md @@ -1573,12 +1573,12 @@ By default, turning on `:label_errors` will also turn off To display an error message with an error summary, you can use the `alert_message` helper. This won't output anything unless a model validation -has failed. +has failed, and additional options will be passed on as attributes to the root `div`: ![Example 49](demo/doc/screenshots/bootstrap/readme/49_example.png "Example 49") ```erb <%= bootstrap_form_for @user_with_error do |f| %> - <%= f.alert_message "Please fix the errors below." %> + <%= f.alert_message "Please fix the errors below.", tabindex: -1, role: "note" %> <% end %> ``` @@ -1586,7 +1586,7 @@ Which outputs: ```html
-
+

Please fix the errors below.

  • Email is invalid
  • @@ -1614,29 +1614,6 @@ This generates: ``` -Additional options will be passed on as attributes to the root `div`: - -```erb -<%= bootstrap_form_for @user_with_error do |f| %> - <%= f.alert_message "Please fix the errors below.", tabindex: -1, role: "note" %> -<% end %> -``` - -This generates: - -```html -
    -
    -

    Please fix the errors below.

    -
      -
    • Email is invalid
    • -
    • Misc is invalid
    • -
    • Preferences is invalid
    • -
    -
    -
    -``` - To output a simple unordered list of errors, use the `error_summary` helper. ![Example 51](demo/doc/screenshots/bootstrap/readme/51_example.png "Example 51") From 701ba4351d33a35de8564aea4a4e5b5a23d43885 Mon Sep 17 00:00:00 2001 From: Larry Reid Date: Fri, 30 Oct 2026 00:07:34 +0000 Subject: [PATCH 5/5] Add v6 to contributing doc --- CONTRIBUTING.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6d17ac81..e15e345a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,6 +10,30 @@ There are a number of ways you can contribute to `bootstrap_form`: - Fix a bug or add a new feature. - Add to the documentation. - Review pull requests. +- **New** [Help migrate to Bootstrap 6](#bootstrap-6). + +## Bootstrap 6 + +Bootstrap 6 is coming, and that means extensive changes to `bootstrap_form`. +We're also going to take advantage of the change in major version number +to make the gem more flexible and easier to use and maintain. +This will mean some breaking changes, if you're migrating from `bootstrap_form` version 5. + +For now, the main thing to keep in mind if you want to submit a PR for the migration to Bootstrap 6, +is to branch your code from the `bootstrap-6` branch in this repository, +and submit your PR to merge on the `bootstrap-6` branch, _not_ `main`. + +If your PR means that something works differently in `bootstrap_form` version 6 compared to version 5, +describe the changes in `UPGRADE-6.0.md`. + +If you want to help test the `bootstrap-6` branch, that's a great way to contribute. +Change your `Gemfile` to read: + +``` +gem "bootstrap_form", git: "https://bootstrap-ruby/bootstrap_form", branch: "bootstrap-6" +``` + +If you find bugs, missing features, or have suggestions, create an issue on GitHub. ## Testing