Fork me on GitHub
#fulcro
<
2022-07-16
>
Fabian14:07:44

I have multiple fulcro rad forms on one page. Im also using the router from rad. How can I avoid each rad form changing the url but still use the routing for certain forms?

Jakub Holý (HolyJak)20:07:44

Use the forms that you do not want to use routers without a router. You will need to start manually the form's state machine via start-form! which normally https://github.com/fulcrologic/fulcro-rad/blob/cb8e2e99711bd30f55b244748c0e4bd15c70668e/src/main/com/fulcrologic/rad/form.cljc#L389

Fabian20:07:40

Yes, I do start them with start-form. When I save the form then, they change the url in the browser to their own route.

Jakub Holý (HolyJak)20:07:07

I guess you call save! , which triggers :event/save which then triggers :event/saved which, as you have observed, https://github.com/fulcrologic/fulcro-rad/blob/cb8e2e99711bd30f55b244748c0e4bd15c70668e/src/main/com/fulcrologic/rad/form.cljc#L1023. The obvious solution is to https://github.com/fulcrologic/fulcro-rad/blob/cb8e2e99711bd30f55b244748c0e4bd15c70668e/src/main/com/fulcrologic/rad/form_options.cljc#L295 for these forms not to do that (look at defstatemachine , it essentially use def's a map so you can take it and assoc-in your variant of :event/saved). You could also ask @U0CKQ19AQ whether it would make sense to extend the check in :event/saved from just (when (history/history-support? fulcro-app) to something like (when (and (history/history-support? fulcro-app) (this form has :route-segment defined) .

Fabian20:07:32

Ah I will override the UISM then. Thank you very much!

tony.kay21:07:25

Ah, yeah, so that’s a good note. It would make more sense for there to be an option you could pass on start of the form to indicate if the form was embedded or standalone, then have the UISM pay attn to that for URL manipulation. If you’d like to make a contribution to the RAD library for that, I’d take it.

tony.kay21:07:18

1. allow parameter :embedded? true to be passed as UISM event data 2. Update initial state in form UISM to store that in local storage (uism/store) 3. Use that value via (uism/retrieve) to modify the history logic

Fabian08:07:28

Okay, I will give it a try! Might take me a while. I will create a PR on github when I have something