How to do fieldlist "partial successful" form subission (v1)? #392
Replies: 2 comments 4 replies
-
This doesn't sounds like a common pattern to me. Would it be better to have each item an individual form so you don't have to deal with partial success but just a list of forms that are either success or failure? The |
Beta Was this translation helpful? Give feedback.
-
Approach 3 seems to have a couple of issues: 1: Example w/ videoex. fieldList of 4 items. The user removes index 1 with `form.remove`, which causes index 2 and 3 to be empty. screencast-localhost_3001-2024.01.25-22_41_08.webm2: Example w/ video1. Submit leads to error state. Click `form.remove`, `form.insert` causing the fieldList to change. The error state is lost 2. Submit leads to error state. One fieldList item is successful and removed with useEffect and `form.remove`. The error state is lost screencast-localhost_3001-2024.01.25-23_07_55.webm |
Beta Was this translation helpful? Give feedback.
-
I want to be able to perform a multi create, where the user can add and remove items as needed, utilizing
getFieldList
,form.insert
,form.remove
.Submitting this form could have three outcomes:
How do remove successful field items, while showing errors?
I tried a couple of approaches for this:
1. Hiding fieldList items
Didn't work since hiding field elements didn't effect the fieldList items.2. Reseting with failed items as defaultValue
Didn't work since reseting the form doesn't allow errors.3. Remove successful fieldList items
Track the indices of the successful fieldList items and form.remove them. Didn't work since this removed the errors.4. Manually hide successful fieldList items
Track the indices of the successful fieldList items and don't render them.The last approach ended up working, but feels convoluted.
Personally, I like the first approaches the most since it feels like it should be supported by the API.
Beta Was this translation helpful? Give feedback.
All reactions