Search code examples
haskellreformdigestive-functors

how can I clear or set values in a digestive-functors view


I have used postForm from Text.Digestive in digestive-functions which returns something like a (Just view, Nothing) in the case of a form error. I can then take the view and render it to HTML to display the form errors.

My issue is that I do not want every field to be rendered as given by the user. Specifically, my captcha value should be reset to a newly computed one rather than reusing the old one (which would give an infinite number of captcha attempts). But I do not know how to compute a new view with one field cleared/set, given the old view.

Alternatively, does anyone know if this would be easier with reform? I haven't looked at it much yet but it seems nice that it does away with the string-based-programming part of digestive-functors.


Solution

  • I repeated the question on the bug tracker where someone eventually came up with a working hack. The view value turns out the be a record. You can mutate its viewInput field before rendering it. viewInput is an association list from paths to forms.