You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
f.input :title, error: "error" should set a custom error message, but the error is completely ignored unless f.object is nil, which is very unlikely for the vast majority of model backed forms.
The bug was introduced in this commit over 6 years ago 09c928f which was added to support errors working when there is no f.object
The issue is the logic then never reaches has_custom_error? if f.object is present, because it either only looks in the object's errors, or fails the object.nil? check when you have an object.
I propose the fix is to just change this line to
object_with_errors? || has_custom_error?
as the custom error is used if it exists and the object.nil? check was not adding any actual benefit. This will find an error on the object if an object exists, or will fallback to the custom error regardless of object being present or not.
The text was updated successfully, but these errors were encountered:
f.input :title, error: "error"
should set a custom error message, but the error is completely ignored unlessf.object
is nil, which is very unlikely for the vast majority of model backed forms.The bug was introduced in this commit over 6 years ago 09c928f which was added to support errors working when there is no
f.object
https://github.com/heartcombo/simple_form/blob/main/lib/simple_form/components/errors.rb#L13
The issue is the logic then never reaches
has_custom_error?
iff.object
is present, because it either only looks in the object's errors, or fails theobject.nil?
check when you have an object.I propose the fix is to just change this line to
as the custom error is used if it exists and the
object.nil?
check was not adding any actual benefit. This will find an error on the object if an object exists, or will fallback to the custom error regardless of object being present or not.The text was updated successfully, but these errors were encountered: