final-form-arrays icon indicating copy to clipboard operation
final-form-arrays copied to clipboard

changeValue function in mutators

Open alex-shatalov opened this issue 7 years ago • 3 comments

bug report or a feature

Hi, find that function changeValue, checks state.fields[name]. In my case form has routes and some mutation logic take place in component that does not have any <Field> or <FieldArray> component. So mutators don't work.

alex-shatalov avatar Jan 22 '18 13:01 alex-shatalov

It, by design, does not allow setting values for fields that are not registered. You have fields that are not registered for which you would like to modify the value?

erikras avatar Jan 22 '18 14:01 erikras

We have something like wizard form. Pages of form renders by it own routes. And final save page has it own route. So when submitting, we need to do some logic, and yes fields are not registered in moment when save page is active.

alex-shatalov avatar Jan 22 '18 14:01 alex-shatalov

We have the same use case and ran into it with File uploads. The graphql/model representation of an uploaded file vs an HTML File object are different, so we had to manipulate the underlying values model. We ended up adding Field components that have no visibility so we could subscribe, and mutate.

I'm about to hit another: We have arrays of Affiliations and Addresses, each has a transient field deleted which is never visible, but allows a user to add/delete at-will then submit at the end of their work (contact form). The backend processes the additions/deletions based on this transient field, but we would never want to show it.

rosskevin avatar Jan 22 '18 16:01 rosskevin