Skip to content

Unable to make all the form fields touched programmatically. #1468

Description

@adityapatil9191

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 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions