File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
lib/simple_form/components Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ def full_error(wrapper_options = nil)
11
11
end
12
12
13
13
def has_errors?
14
- object && object . respond_to? ( :errors ) && errors . present ?
14
+ object_with_errors? || object . nil? && has_custom_error ?
15
15
end
16
16
17
17
def has_value?
@@ -34,6 +34,10 @@ def full_error_text
34
34
has_custom_error? ? options [ :error ] : full_errors . send ( error_method )
35
35
end
36
36
37
+ def object_with_errors?
38
+ object && object . respond_to? ( :errors ) && errors . present?
39
+ end
40
+
37
41
def error_method
38
42
options [ :error_method ] || SimpleForm . error_method
39
43
end
Original file line number Diff line number Diff line change @@ -224,6 +224,12 @@ def with_full_error_for(object, *args)
224
224
assert_no_select 'span.error'
225
225
end
226
226
227
+ test 'input with custom error works when form does not use a model' do
228
+ with_form_for :user , :active , error : "Super User Active! cannot be blank"
229
+
230
+ assert_select 'span.error'
231
+ end
232
+
227
233
test 'input with custom error works when using full_error component' do
228
234
swap_wrapper :default , custom_wrapper_with_full_error do
229
235
error_text = "Super User Name! cannot be blank"
You can’t perform that action at this time.
0 commit comments