Skip to content

Form Actions throw error if one if the form field name is also action #7593

Description

@xmlking

Describe the bug

When we have one of the form field name as action it is conflicting with the form's action and throw following error

image

Reproduction

create a form with one of the field name as action

<form class="space-y-6" method="POST" action="?/save" use:enhance>
      <input type="text" name="action"  id="action"    value={policy.action} />
      <button>Save</button>
</form>

Logs

forms.js?v=360cc9a6:50 Uncaught (in promise) TypeError: Failed to construct 'URL': Invalid URL
    at HTMLFormElement.handle_submit (forms.js?v=360cc9a6:50:18)
    at HTMLFormElement.sentryWrapped (helpers.ts:98:1)

System Info

System:
    OS: macOS 13.0
    CPU: (10) arm64 Apple M1 Max
    Memory: 30.77 GB / 64.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.11.0 - /opt/homebrew/bin/node
    npm: 8.19.2 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 107.0.5304.110
    Safari: 16.1
  npmPackages:
    @sveltejs/adapter-auto: 1.0.0-next.87 => 1.0.0-next.87 
    @sveltejs/adapter-node: 1.0.0-next.100 => 1.0.0-next.100 
    @sveltejs/adapter-static: 1.0.0-next.48 => 1.0.0-next.48 
    @sveltejs/kit: 1.0.0-next.538 => 1.0.0-next.538 
    svelte: 3.52.0 => 3.52.0 
    vite: 3.2.3 => 3.2.3

Severity

annoyance

Additional Information

I have this form before migrating to the new Form Actions to create/update my form data. I was using svelte-forms-lib and using fetch to post data before and was working. now when I am trying Form Actions, I noticed this bug

export const actions: Actions = {
	save: async ({ request }) => {
		const formData = await request.formData();
		console.log('save action formData:', formData);
		return {
			success: true
		};
	}
};

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions