Unable to make all the form fields touched programmatically. #1469
Unanswered
adityapatil9191
asked this question in
Need help
Replies: 1 comment
-
Hey, please do not create issues when needing a help with code, discussions are better place. I think you need to call |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello ,
I want to make all the form fields touched, once user moves from one accordion to another, in the given example .
https://codesandbox.io/p/sandbox/react-data-driven-autocomplete-forked-9tkfvt?file=%2Fsrc%2FForm.jsx%3A17%2C26.
The below code does not work . Can anyone please help me if I am doing anything wrong here?
const formOptions = useFormApi();
const {lastOpened, setFormState} = useAppContext();
const {fields} = useFieldsApi(props);
//This if condition is to extract all the fields which were last opened and it is working as expected.
if (fields && fields.length) {
const filteredFieldItems = fields.filter((field:any)=> field.name === lastOpened)
}
if(filteredFieldItems && filtteredFieldItems.length) {
filteredFieldItems[0].fields.forEach((field:any)=> {
formOptions.focus(field.name);
})
}
The line highlighted above does not focus the fields. Is that a correct syntax? I am able to extract the fields .
Beta Was this translation helpful? Give feedback.
All reactions