Next.js Discord

Discord Forum

Multiple accordions and having a individual form inside each of them

Unanswered
Yellow croaker posted this in #help-forum
Open in Discord
Yellow croakerOP
Hello so in my application user can add, remove, modify workExperiences. I have each individual form inside their own accordion. What way i should deal with them so that user can send them as individual forms to my backend? Currently i'm using useFieldArray (from React Hook Form) that sadly sends the whole array to my backend, and sending all workExperiences to backend when modifying one feels awkward.
Here is somewhat barebone example of the functionality on stackblitz.
https://stackblitz.com/edit/stackblitz-starters-a9dlzp?file=app%2FWorkExperienceDetail.tsx
So basically what i want: If user submits the first form in stackblitz, it sends that form data to the backend and not the whole array. Is using useFieldArray here necessary?
I'm using nextjs 14.0, server actions and shadcn

0 Replies