Skip to content
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

Form field keys conflict with form object APIs #2156

Open
LucaPuddu opened this issue Dec 27, 2024 · 0 comments
Open

Form field keys conflict with form object APIs #2156

LucaPuddu opened this issue Dec 27, 2024 · 0 comments

Comments

@LucaPuddu
Copy link

Version:

  • @inertiajs/vue3 version: 2.0.0

Describe the problem:

Specific field names cause undefined behavior.
There is a number of keys that should not be used as field names, progress being one of those, as they are already exposed as properties of the form object.

Other than the default field value not working properly unless the form is reset, it's possible that the field could be overwritten altogether when the form is being submitted.

Steps to reproduce:

const form = useForm({
  progress: 0,
});

console.log(form.progress); // null, but it should be 0

form.reset();

console.log(form.progress); // 0

Possibile solutions

Honestly I can't think of a way to change the API without adding breaking changes. The most logical way would be to group the fields under a separate object, something like form.data.progress for your field and form.progress for the already available progress event.

At minimum, the initialization should throw an error when certain "reserved" keys are being used as fields. Any other idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant