How to perform a "PATCH " and "PUT" functionality using server actions to a nested form component ?
Unanswered
Long-horned bees posted this in #help-forum
Long-horned beesOP
I'm fairly new to Next.js server actions and want to try out a few things. Within my app/admin/products page, data is fetched from MongoDB to return all products and mapped with edit and delete buttons. The thing is, I wish to use the same input fields (form) to perform product editing and product creating. I'm unsure how to invoke server functions and populate the form with the requested product patch ID data.
1 Reply
@Long-horned bees I'm fairly new to Next.js server actions and want to try out a few things. Within my app/admin/products page, data is fetched from MongoDB to return all products and mapped with edit and delete buttons. The thing is, I wish to use the same input fields (form) to perform product editing and product creating. I'm unsure how to invoke server functions and populate the form with the requested product patch ID data.
you should probably render a
<input type="hidden" name="isCreating" value="<true or false>" /> then based on the value of formData.get("isCreating"), run the corresponding logic in the server action