Skip to content

Conversation

@alec-c4
Copy link
Contributor

@alec-c4 alec-c4 commented Nov 21, 2025

The Svelte scaffold generator created broken new.svelte files that caused runtime errors when creating new records. This issue affected all 4 Svelte scaffold templates (with/without Tailwind, with/without TypeScript) but NOT React or Vue

Root cause: All Svelte new.*.svelte.tt templates incorrectly used <%= js_resource_path %> for the Form action, which expands to #{route_url}/${#{singular_table_name}.id}. For a new record, post.id is undefined, resulting in an invalid URL like /posts/undefined and causing a TypeError.

Additionally, one template (inertia_tw_templates/scaffold/templates/svelte/new.svelte.tt) included an invalid onSubmit={handleSubmit} prop that referenced an undefined function, causing a ReferenceError.

Before (broken):

  <Form
    {post}
    submitText="Create Post"
    onSubmit={handleSubmit}
    action="/posts/${post.id}"  <!-- post.id is undefined -->
    method="post"
  />

After (fixed):

  <Form
    {post}
    submitText="Create Post"
    action="/posts"  <!-- Correct collection path -->
    method="post"
  />

@alec-c4
Copy link
Contributor Author

alec-c4 commented Nov 21, 2025

@skryukov there was a typo in your commit a0e7129

@bknoles bknoles merged commit ab47bf9 into inertiajs:master Nov 21, 2025
31 checks passed
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

Successfully merging this pull request may close these issues.

2 participants