reform icon indicating copy to clipboard operation
reform copied to clipboard

Coerced values remain in the form when rerendering the view on failed validation

Open bolstycjw opened this issue 7 years ago • 0 comments

Complete Description of Issue

When using coercion with Reform, the raw date strings are coerced into Date types during validation. If validation fails, the values remain as the coerced types. This results in incorrect date format display when the form is rerendered on the view.

Steps to reproduce

class FooForm < Reform::Form
  feature Coercion

  property :date, type: Types::Form::Date

  validation do
    required(:date).filled(:date?)
  end
end

Expected behavior

Reform should revert the form values to their original raw input when validation fails.

Actual behavior

Form values are persisted in the form object even if validation fails and input is invalid.

System configuration

Reform version: 2.2

bolstycjw avatar Jan 10 '18 07:01 bolstycjw