Replies: 10 comments 2 replies
-
I've implemented a Note that it's not a drop-in replacement for |
Beta Was this translation helpful? Give feedback.
-
+1 for setting nested properties with dot notation 👍🏻 |
Beta Was this translation helpful? Give feedback.
-
For this I created my own useForm and inside it the setData function is updated with lodash import {set} from "lodash/fp";
import {useForm as useInertiaForm} from "@inertiajs/inertia-react";
export function useForm(...args){
const form = useInertiaForm(...args);
function setData(key, value){
form.setData(
function (data){
return set(name, value, data);
}
);
}
return { ...form, setData}
} |
Beta Was this translation helpful? Give feedback.
-
I created a PR for this to hopefully start a discussion about whether this should be included. I only changed the React version since I don't know Vue or Svelte. |
Beta Was this translation helpful? Give feedback.
-
Any update? |
Beta Was this translation helpful? Give feedback.
-
I created a solution for this and published it as an npm package if it helps anyone. It also has all of the extra things I needed in order to have a full featured form library based on Inertia. |
Beta Was this translation helpful? Give feedback.
-
Big + for this feature. @reinink I think it would be really useful to implement in core. |
Beta Was this translation helpful? Give feedback.
-
Is there any news on this? I would really appreciate this being in the core of inertia. |
Beta Was this translation helpful? Give feedback.
-
Any update on this ?? |
Beta Was this translation helpful? Give feedback.
-
Since Rails and Laravel both expect form data as nested objects by default, could that be supported by
useForm
?Currently, the only ways to submit nested data are to either rely on the
transform
method, which is currently unreliable, or manually submit the data usingInertia.post
.I would like to be able to define a form as such:
Currently, the way I achieve this is as follows:
The issue I have with the current way to achieve this is that I'm breaking down the data to put it into the form, then building it back up in the transform method to submit it back to the server in the original form. I would appreciate the liberty of only using the transform method when I actually need to transform data. Currently, I need to rely on transform every time I submit data since Rails expects form data to be nested in a root property.
Thank you
Beta Was this translation helpful? Give feedback.
All reactions