mobx-react-form icon indicating copy to clipboard operation
mobx-react-form copied to clipboard

field.set(obj) doesn't update form.touched and form.changed

Open Vargentum opened this issue 7 years ago • 3 comments

I have a field with an empty object as initial value. I'm using field.set to dynamically add some new keys. It works good, but form properties (touched, changed) don't reflect these changes.

Also, could you provide some examples how to deal with Array and Object values? Current docs don't clarify this enough.

Vargentum avatar Nov 01 '17 09:11 Vargentum

Right now the set() method doesn't change other fields props.

I need to think more about how to handle this, as the set() method doesn't handle specific behavior for each props right now.

About dealing with complex fields structure, did you take a look to the demo repo?

foxhound87 avatar Nov 04 '17 12:11 foxhound87

Same issue for me. form.set('changed', true) as simple temporal fix is not allowed neither so for now there is not a way to change form state manually? (at least until we find a solution).

andfk avatar Nov 27 '17 12:11 andfk

It feels rather intuitive that you need to call form.select(field).onUpdate(value) to actually update a changed flag. Took me quite some time to figure that out from source code :(

danielkcz avatar Apr 06 '18 18:04 danielkcz

:tada: This issue has been resolved in version 5.8.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Apr 02 '23 11:04 github-actions[bot]

From version 5.8 field set() will trigger onChange hook on ‘changed’ field prop increment.

‘touched’ prop is changed only if the user interact with inputs

foxhound87 avatar Apr 02 '23 11:04 foxhound87