-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] useForm Support For Array of Records (ids) #6657
Comments
Hello @aress31 thanks for the issue. I think you can use https://refine.dev/docs/data/hooks/use-update-many Also could you elaborate your case in more details? I don't think we can update useForm to accept multiple ids, since that would be very complicated change because of dependencies on useForm, but we may think about a new hook if it's a common case that can't be handled with existing hooks. |
@BatuhanW, this approach forces users to reimplement controls already available in It is entirely possible to submit an array of records, and Currently, with For example, imagine a scenario with a |
@aress31 I think you have a misunderstanding with what a fieldArray is. It's a form for a single array field for the same resource. If you check the examples in the link you provided and their sandboxes, form data is submitted to a single entity, with an array field, which includes items from the useFieldArray. It doesn't send these fields to multiple entities. I don't think it would be enterprise-grade UX to select multiple records in the list page, each records having an array of fields, updating all of them at once. Can't really wrap my head around the UI as well, when you select multiple records, you need to have fields for each of them, each of them being an array that user can append, remove records to the same field. If you have an example with RHF, would like to inspect and see what we can do. If you want to update single field of multiple records, it's possible with updateMany. User may select 5 records, and selects a status from the dropdown, let's say rejected. Then you can submit You can see the relevant example here: https://refine.dev/docs/examples/table/mui/useUpdateMany/ |
No misconception here—it is entirely feasible to use ArrayField to handle an array of records. Many applications, such as QuickBooks, support batch editing. I’ll attach a video capture later to demonstrate a use case. |
Is your feature request related to a problem? Please describe.
The issue is that currently,
useForm
cannot be used together withuseFieldArray
becauserefineCoreProps.id
only accepts the id of a single record, rather than an array of records to either create or update.Describe alternatives you've considered
N/A
Additional context
Code snippet example:
Describe the thing to improve
useForm.refineCoreProps.id
should accept an array (useForm.refineCoreProps.ids
), and theonFinish
function returned byuseForm
should be adapted accordingly.The text was updated successfully, but these errors were encountered: