-
Notifications
You must be signed in to change notification settings - Fork 250
Form fields not known when reducer is created #631
Comments
Have you tried using the |
No. I did not find that mentioned in https://davidkpiano.github.io/react-redux-form/docs/api/Control.html or similar pages. Where is it documented? |
I'm still trying to understand what exactly you're trying to accomplish. Do you want to asynchronously set initial values for each field? If so, use actions.load(model, value): somePromise().then((values) => {
// This will set the initial state of foo.bar to the values
dispatch(actions.load('foo.bar', values));
}); |
This shows what I am trying to do. When you click the Add Fields button, it updates Adding At this point, I know how to do what I want to do, but I think that the documentation does not mention |
Addresses davidkpiano#631.
I have a page which does something along these lines.
If the returned data is
{a: 1, b: 2, c: 3}
, I will create a form with three fields, labeled a, b and c. These values are stored in the model atfoo.bar.a
,foo.bar.b
, ... If the returned data is{a: 1, b: 2, d: 4, e: 8}
, then I create a form with four fields (a,b,d,e). This worked fine when I was using a ReactForm
, since I could set up a default value for each field.react-reduce-form
does not, as far as I can tell, support default values, but requires that the value be in the model.Since I initialize the store before I know what the fields will be, I cannot set them in the initial state. There is not even a finite set of possible values, so I cannot preset all possible values.
My
render
method currently looks something likeDo I instead need to do something like
The text was updated successfully, but these errors were encountered: