Open bpicolo opened 8 years ago
In your example, you're creating the doc
atom once the first time the form is rendered. That code will not be rerun on changes to foo
. The only way to do this right now would be to pass foo
directly to bind-fields
. Unfortunately, not all the fields can handle external updates so YMMV with that approach.
@yogthos
The question is more this. I want to populate a form with some data I fetch asynchronously. How can I make sure that, given I start with no data and render an empty form, then load data to populate it, how to I make sure it's populated with that latter data?
Currently, the data has to be available at the time bind-fields
runs. This is the same issue as https://github.com/reagent-project/reagent-forms/issues/19 where the atom has to be updated externally after the form is created.
Actually, it appears to work properly for textbox, and I have a fix for :list. It looks like radio groups and selection groups have this problem still. It looks like a minor fix to handle, I may give it a try for some other fields...
Yeah that looks promising, if you think you can get it to work I'd love a pr for this.
Tested fix for single-select for selection groups. See mods at https://github.com/khdegraaf/reagent-forms. Multi-select may be fixed too, but haven't tested it. Did test and verify checkbox, textbox (and presumably variations), and datepicker all work in my project. I haven't tested the others. I'll do a push request at some point.
Fantastic, thanks for spearheading this.
I believe I'm hitting similar behavior to a few of the other issues, but it's quite unclear how to resolve.
I have a form as so:
The issue is, when some-form is re-rendered (because a level above it is reacting to @\foo), the form does not seem to re-render. (If I throw in a some text field reacting to @\doc here, the text field will update)
What is the proper way to handle this? It's not quite that I am updating the atom externally, it's that I'm asynchronously loading the data that goes into the atom. I want to replace it entirely.