diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f3e412f..63dc36f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 23.0.0 / unreleased +* [BUGFIX] `form_with` default argument exception on Rails 8.0 ([#974](https://github.com/DavyJonesLocker/client_side_validations/issues/974)) * [FEATURE] Breaking change: Add `csv` prefix to CSV related data attributes: - `data-changed` => `data-csv-changed` - `data-valid` => `data-csv-valid` diff --git a/lib/client_side_validations/action_view/form_with_helper.rb b/lib/client_side_validations/action_view/form_with_helper.rb index 720afd42..91ace484 100644 --- a/lib/client_side_validations/action_view/form_with_helper.rb +++ b/lib/client_side_validations/action_view/form_with_helper.rb @@ -4,7 +4,7 @@ module ClientSideValidations module ActionView module Helpers module FormHelper - def form_with(model: nil, scope: nil, url: nil, format: nil, **options, &block) + def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block) return super unless options[:validate] options[:allow_method_names_outside_object] = true diff --git a/test/action_view/cases/test_form_with_helpers.rb b/test/action_view/cases/test_form_with_helpers.rb index 9cf5a3c3..9e85396b 100644 --- a/test/action_view/cases/test_form_with_helpers.rb +++ b/test/action_view/cases/test_form_with_helpers.rb @@ -67,6 +67,14 @@ def test_form_with_automatically_generate_ids assert_dom_equal expected, output_buffer end + def test_form_with_skip_validate + assert_nothing_raised do + form_with(validate: false) + end + + assert_dom 'form' + end + BASE_FIELD_HELPERS.each do |field_helper, options| define_method(:"test_form_with_#{field_helper}") do form_with(model: @post, validate: true) do |f|