Skip to content

Commit

Permalink
Fix: form_with with validate: false exception on Rails 8
Browse files Browse the repository at this point in the history
Ensure that super `form_with` is called with the right arguments.

Fix #974
  • Loading branch information
maxnovee committed Jan 29, 2025
1 parent 96ef17d commit bbaac22
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions test/action_view/cases/test_form_with_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down

0 comments on commit bbaac22

Please sign in to comment.