diff --git a/README.md b/README.md index b233c2d3..3f001b9d 100644 --- a/README.md +++ b/README.md @@ -233,6 +233,7 @@ The current configuration options are: | Option | Default value | Description | |---------------------------|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `default_form_attributes` | {} | `bootstrap_form` versions 3 and 4 added a role="form" attribute to all forms. The W3C validator will raise a **warning** on forms with a role="form" attribute. `bootstrap_form` version 5 drops this attribute by default. Set this option to `{ role: "form" }` to make forms non-compliant with W3C, but generate the `role="form"` attribute like `bootstrap_form` versions 3 and 4. | +| `turbo_submits_with` | {} | Add custom content to a submit button while the request is processing. Try `c.turbo_submits_with = :spinner` to use the built-in spinner, or pass a custom HTML string. Caveat: Only works on `form.primary` or `form.button` as `form.submit` renders a `input` field which only accepts a string and not an HTML element. Settings this also forces `render_as_button` on `form.primary` | Example: diff --git a/lib/bootstrap_form/configuration.rb b/lib/bootstrap_form/configuration.rb index fdd2e0d2..d5a73689 100644 --- a/lib/bootstrap_form/configuration.rb +++ b/lib/bootstrap_form/configuration.rb @@ -25,6 +25,25 @@ def default_form_attributes MESSAGE BootstrapForm.config.default_form_attributes end + + def turbo_submits_with=(value) + case value + when nil + @turbo_submits_with = nil + when :spinner, "spinner" + @turbo_submits_with = "