Fork me on GitHub
#malli
<
2022-07-09
>
Panel23:07:50

Would anyone has anything to share regarding generating Web Form from Malli ? I have seen multiple conversations, blog post and even conf talk but none of those have code. Thanks

eskos07:07:53

I suppose it would require a bit indirect and more involved route to approach, since having somesuch library would need to make assumptions about nesting, specific form events, usability issues (think tab navigation, grouping, aria tags...). So maybe the reason is that no one's just yet done a good enough system they're comfortable with abstracting to a library 🙂

valtteri08:07:54

This is something we're doing ad-hoc in different projects. We've discussed about wrapping the best practices into a lib and open sourcing it. But I'd say the status is still “cooking”

Panel08:07:43

Sounds like the interceptor pattern, everyone using it code a new implementation to fit their needs. @U6N4HSMFW can you share describe how you do it ? Do you walk the schema and generate hiccup ? Do you have 2 data structures, one for the validation and one to describe UI specifics ? One option I played with is to use a JS lib that accept json-schema, that did not work out for you ?

valtteri10:07:03

JSON-schema is fine for simple cases and if that works for you then that’s a perfectly valid way to go in my opinion.

valtteri10:07:16

We’ve tried it both ways you described. Just a couple of months ago a colleague demoed “walking malli schema and generating hiccup” approach.

valtteri10:07:45

I think the “generate ui from schema” approach pays off if you have really complex forms and a lot of them

valtteri10:07:10

Or when you need to dynamically generate the forms

🎯 1
valtteri10:07:18

I think you could also get quite far with something like Formik + malli validation

geraldodev00:07:52

@U6N4HSMFW the malli piece is set on stone for me, as for the react library, could you please elaborate why that were choosen ? Was it the better at the time, has it a feature that more inline with the approach that you are using. I've started to look into react-hook-form https://github.com/geraldodev/react-form-hook-test/blob/use-form-state/src/main/app/core.cljs#L45 but I've stopped. Going back to it soon. Today my colleague pointed me to https://github.com/tannerlinsley/react-form , In the last two weeks I'm learning that code from tanner have high quality, I briefly looked today one example. It looked that it gets too deep into validation. It would be nice a library that interact with DOM (react) just enough and gives as the hooks (not react) points to bring malli awesomeness to our beloved clojure data strutures. I'm following this rabbit hole. Are you too ?