You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #72, support for Inertia transform was added. However, it looks like it does not support renaming keys, or changing the data structure. In fact, it looks like it only supports transforming individual form field values.
If keys are renamed, or the data structure changes when transforming, then validation is not triggered.
I would expect that changing the data structure with transform is possible and fully supported.
Steps To Reproduce
Implement a form like this:
constform=useForm('patch','/update',{document: {customer: {email: '[email protected]'}/** other data here **/}}).transform((data)=>{ ...data.document})
I think the issue might be that the originalnputs array serves 2 different purposes:
A stored list of original data keys, so it's easier to reset the form data
A list of keys which is used to remove the non-data form properties from the form when calling form.data()
The issue here is that originalInputs is never updated, not even when calling form.setData() with a completely different object than when initializing. However, since originalInputs is used to reset form data to initial state, this seems an expected behavior in that regard...
Perhaps it would make more sense to have a dedicated dataKeys array, which is updated whenever setData is called?
Also, I haven't tested yet wether precognition forms support Inertia's form.defaults()?
Laravel Precognition Plugin Version
0.5.6
Laravel Version
10.41.1
Plugin
Vue w/ Inertia
Description
In #72, support for Inertia transform was added. However, it looks like it does not support renaming keys, or changing the data structure. In fact, it looks like it only supports transforming individual form field values.
If keys are renamed, or the data structure changes when transforming, then validation is not triggered.
I would expect that changing the data structure with
transform
is possible and fully supported.Steps To Reproduce
Implement a form like this:
Changing the
email
value will trigger validation all the way until this line:precognition/packages/vue/src/index.ts
Lines 87 to 90 in 78d440b
It stops here, because the keys in
originalInputs
are based on the initial data, without applying the transformer on it.The text was updated successfully, but these errors were encountered: