sveltekit-superforms icon indicating copy to clipboard operation
sveltekit-superforms copied to clipboard

inconsistent behavior between fieldProxy and formFieldProxy with nested data

Open Alessandro-Mezzogori opened this issue 1 year ago • 3 comments

  • [x] Before posting an issue, read the FAQ and search the previous issues.
  • [ ] If you're posting a bug for Superforms v2, make sure you're on the latest alpha version with npm i -D sveltekit-superforms@alpha.

Description proxying an inner field of an undefined ( or null ) parent object behaves differently with FormFieldProxy and FieldProxy in regards of creating the parent if it doesn't exist.

  • FieldProxy: creates the parent only if it is undefined
  • FormFieldProxy: doesn't create the parent in any case

this leads to values of the forms being displayed in the input element but not being set in the backing json object.

If applicable, a MRE MRE: https://stackblitz.com/~/edit/sveltekit-superforms-1-testing-nxq1t8?file=src%2Froutes%2F%2Bpage.server.ts,src%2Froutes%2F%2Bpage.svelte

Alessandro-Mezzogori avatar Feb 03 '24 11:02 Alessandro-Mezzogori

This is fixed in v2, where the parent will always be created if undefined. If you can upgrade it will work, otherwise, you'll have to wait for the next release, which may be a while since I'm focusing on releasing v2 right now.

ciscoheat avatar Feb 03 '24 20:02 ciscoheat

thanks for the quick response and for the awesome library! will try to upgrade.

Alessandro-Mezzogori avatar Feb 04 '24 01:02 Alessandro-Mezzogori

Reopening, as it needs to be fixed in v1.

ciscoheat avatar Feb 08 '24 10:02 ciscoheat

Won't be fixed, as v3 is taking shape.

ciscoheat avatar Aug 12 '24 06:08 ciscoheat