formio.js icon indicating copy to clipboard operation
formio.js copied to clipboard

Setting value asychronously via API does not trigger dependent actions on other fields.

Open Vedhachala opened this issue 6 years ago • 4 comments

Hello formiojs team,

I am able to set value to a field (say text1) after calling a rest API by using the suggested instance.updateValue method.

Now I have configured my text2 field to be hidden (using conditional tab) on text1's value from the API. This does not work when I use the instance.updateValue method.

It is not just the hidden property, dependent "logic actions" or the "redraw on" options also does not work when setting values with API

Note: I am not using instance.setValue because it causes an infinite loop. Also, the method documented here can neither be configured from a formbuilder nor injected in some way to the form json.

Any suggestions to make this work would be very helpful.

Thanks, Vedhachala

Vedhachala avatar Jul 14 '20 15:07 Vedhachala

Hello @Vedhachala, can you please provide a JSFiddle of this issue occurring so that we can investigate further?

Thank you.

wag110894 avatar Jul 14 '20 16:07 wag110894

@wag110894 I figured that I am still facing the loop issue with instance.updateValue also. It seemed that the updateValue method was not causing the loop because the value in the field's UI was not reset when I change the value. But the submission data variable is still not changing, it is always the value that was set from the API and I am unable to change it. The custom default value get called with every change in the field again, hence making it impossible to change the value.

Here is the jsfiddle of the observed loop behavior

I apologize for the mismatch in the context of the bug title and Description, We can track this is in a different issue if you guys want

Vedhachala avatar Jul 16 '20 16:07 Vedhachala

If you are manually assigning values you may need to call triggerChange() to cause the events system to fire.

randallknutson avatar Jul 16 '20 21:07 randallknutson

Closing this thread as it is outdated. Please re-open if it is still relevant. Thank you for your contribution!

Tatsiana8 avatar Jan 31 '24 14:01 Tatsiana8