Closed colinf closed 8 years ago
One day on & I think my previous post showed some Cerebral naïvety! I now think it's better to instantiate the form and set the state with it once the values are known. So in the same action this is now:
const {teams, selectedId} = state.get();
const team = teams[selectedId];
state.set(['teamInputForm'], makeForm(team));
May well still be naïve but it seems to work!
@colinf Sorry for not answering, have been on holiday 👍 . When instantiating the form you should do something like
teamInputForm: Form({
name: {
value: '' // initial state
},
id: {
value: '' // initial state
}
})
You can also use defaultValue for this. Or maybe I understood it wrong?
I hope you had a good holiday! Thanks for the response - I think I got there in the end.
None of the demo projects seems to cover the use case of a form used for updating data, in all cases the 'value' of each field is set when the form is added to state. To make it work I am using code along the following lines in an action when the update form (teamInputForm) is opened:
Is this the best way to approach this? I'm happy to contribute an update form example to the demos if anyone can confirm the best approach.
Thanks, Colin