hyperfiddle

braai engineer 2025-09-06T13:21:10.643439Z

Forms v5 bug: recently reported a Forms v5 error via @xifi when passing :required true to forms/Input!, but is not specific to required – the same behaviour occurs when returning ex-info from :Parse. Symptoms: 1. SubmitButton! is initially enabled despite empty Input (I'm aware of initial Parse / checker wart) 2. Enter a string into Input! and clear it – form state now has a required exception. Submit button remains enabled. 3. Click submit button. It then disables and remains disabled. 4. Type something into Input!, which should clear exception, but submit button remains disabled. 5. Cannot re-submit form for required fields that are subsequently filled. Repro:

(forms/Service {::run-foo (e/fn [_] [::forms/ok])}
  (forms/Form! {}
    (e/fn Fields [_]
                 (e/amb
                   (forms/Input! :foo "" :Parse (e/fn [s] (if (string/blank? s) (ex-info "required" {}) s)))
                   (forms/SubmitButton! :label "GO" :class "btn btn-primary")))
    :Parse (e/fn [m _]
             (prn 'form-state m (js/Date.))
             [::run-foo m])))
Discovered because I need to make some fields required, so I tried to override :Parse. Could it be related to default Unparse = (Lift str)? I tried setting Unparse, but same behaviour:
(forms/Input! :foo ""
  :Parse (e/fn [s] (if (string/blank? s) (ex-info "required" {}) s))
  :Unparse (e/fn [s] s))
Update: OK, this seems to happen because I was returning [::run-foo m] where m has ex-info's. if I check for any ex-message in the Form!'s :Parse fn and return ex-info from Form :Parse, it seems to behave as expected:
:Parse (e/fn [m _]
         (prn 'form-state m (js/Date.))
         (let [valid? (not-any? ex-message (vals m))]
           (if valid?
             [::run-foo m]
             (ex-info "invalid form fields" {}))))

Geoffrey Gaillard 2025-09-08T09:13:17.028339Z

Thank you for reporting. Glad to see you’ve found a workaround. We’ll look into it.