Include data in resulting object from form.getState()
msageryd opened this issue · comments
feature request
I've just discovered mutators. They are awesome!
I'm adding data to my fields with final-form-set-field-data
. I also learned that I can initialise the data property when registering the fields. (#240 (comment))
Since data seems to be the decided property name for arbitrary field data it would be great to get the data property for all fields from form.getState()
.
Proposed solution
This feature would be simple to implement by piggy-backing on the existing reduce function in calcNextFormState()
Line 554 in a2047e0
My user-land solution is to reduce over getRegisteredFields
at submit, like this:
const data = form.getRegisteredFields().reduce(function(result, key) {
result[key] = form.getFieldState(key).data;
return result;
}, {});
I would really like form.getState() to output a data-object. I also think others would benefit from this.
I could make a PR if this is interesting.