Fork me on GitHub
#luminus
<
2020-10-09
>
Steven Deobald19:10:40

Is there a sensible way (suggested library, maybe) to deal with repeated data in forms? I have a form which permits a dynamic list of identical fields. Right now, they're coming across as fairly simple/dumb names:

{:pali "mangal2", :translation-1 "first", :translation-2 "second", :submit "Save"}
...I've just tacked on the -1 and -2 suffixes with a tiny JavaScript blurb when an extra translation field is dynamically added to the form. I'd love to keep this web UI extremely limited in terms of how much JavaScript is actually required, but I can't see anything out there in the Clojure web world that does something similar to Rails' one-to-many fields_for: https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-fields_for-label-One-to-many Is this sort of client/server complexity just not a thing anymore? Any time I see even a remotely complicated web app in Clojure, the front end is always in ClojureScript/reagent, posting to JSON endpoints. Which is fine, I guess... I could adopt that approach... but something stubborn in me would love to do it the old-fashioned way. 😉

Steven Deobald19:10:48

https://github.com/jkk/formative is the only thing I've found so far that even really approaches this problem, but it doesn't appear to have a solution for this specific situation of 1-to-n relationships represented as lists of form inputs automatically translated into a vector on the server side. It also looks quite stale.