Get all values (even the empty ones) from Redux Form on Submit

233 Views Asked by At

I need to get an object with all the field values (even the empty ones) when submitting a redux-form based form, because I am setting relay variables and it seems I need to reset them all explicitly.

Currently values, and the selector getFormValues return an object with the values of only the fields that have a value !== "", so I am forced to do a workaround such a selector of this kind:

const getAllValuesSelector = (state) => {
  const formName = "ExampleForm";
  const registeredFields = state.form[formName].registeredFields;
  return registeredFields.reduce((memo, field) =>
   ({ ...memo, [field.name]: getFormValues(formName, field.name) }), {});
};

Which is a bit complex, is there a simpler solution to this problem?

1

There are 1 best solutions below

0
On BEST ANSWER

Which is not very nice, is there a better alternative to this?

Not currently, no.