react icon indicating copy to clipboard operation
react copied to clipboard

Server data triggers validation on new empty required controls

Open Andrey-Pavlov opened this issue 5 years ago • 3 comments

I have the next setup:

const [form, setForm] = useState({});
const [submission, setSubmission] = useState({});

useEffect(() => {
httpGetAndSetForm();
httpGetAndSetSubmission();
  }, [itemId]);

It automatically triggers validation even on new empty inputs. How to disable validation check on initial setup?

image

Andrey-Pavlov avatar Jul 02 '20 12:07 Andrey-Pavlov

I'm not sure what is causing this. by default our forms do not show validations until they are marked as "dirty", meaning that a user has interacted with them or attempted to submit the form. Can you share an example of how you are using the form in react?

randallknutson avatar Jul 02 '20 14:07 randallknutson

I'm not sure what is causing this. by default our forms do not show validations until they are marked as "dirty", meaning that a user has interacted with them or attempted to submit the form. Can you share an example of how you are using the form in react?

I can't create a pure example. My steps are: 1) create a simple form 2) submit the form 3) add a new question to the form 4) when I open the form it triggers validation automaticaly on the new added form components.

Any solutions to don't trigger validation? Can I reset validation manually?

Andrey-Pavlov avatar Jul 31 '20 13:07 Andrey-Pavlov

The form instance has a "resetValue()" function and a "setPristine(true)", both of which will reset the form back to how it originally was.

https://github.com/formio/formio.js/blob/master/src/Webform.js#L1019

randallknutson avatar Jul 31 '20 15:07 randallknutson

I am closing the issue as it was created too long ago and there are no new comments here. I hope it was resolved. If not, please reopen it. Thanks!

TanyaGashtold avatar Aug 31 '23 13:08 TanyaGashtold

Hello @TanyaGashtold. It was not fixed but I changed multiple projects, workplaces and got a child. Thank you.

Andrey-Pavlov avatar Aug 31 '23 19:08 Andrey-Pavlov