Skip to content

Commit 77a4aa4

Browse files
authored
Fix: form_with with validate: false exception on Rails 8 (#975)
Ensure that super `form_with` is called with the right arguments. Fix #974
1 parent 96ef17d commit 77a4aa4

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 23.0.0 / unreleased
44

5+
* [BUGFIX] `form_with` default argument exception on Rails 8.0 ([#974](https://github.com/DavyJonesLocker/client_side_validations/issues/974))
56
* [FEATURE] Breaking change: Add `csv` prefix to CSV related data attributes:
67
- `data-changed` => `data-csv-changed`
78
- `data-valid` => `data-csv-valid`

lib/client_side_validations/action_view/form_with_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module ClientSideValidations
44
module ActionView
55
module Helpers
66
module FormHelper
7-
def form_with(model: nil, scope: nil, url: nil, format: nil, **options, &block)
7+
def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block)
88
return super unless options[:validate]
99

1010
options[:allow_method_names_outside_object] = true

test/action_view/cases/test_form_with_helpers.rb

+8
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ def test_form_with_automatically_generate_ids
6767
assert_dom_equal expected, output_buffer
6868
end
6969

70+
def test_form_with_skip_validate
71+
assert_nothing_raised do
72+
form_with(validate: false)
73+
end
74+
75+
assert_dom 'form'
76+
end
77+
7078
BASE_FIELD_HELPERS.each do |field_helper, options|
7179
define_method(:"test_form_with_#{field_helper}") do
7280
form_with(model: @post, validate: true) do |f|

0 commit comments

Comments
 (0)