Sha256: 2af1b99eaba77cedbf7db715e5f9b24261a544b917b4d4a4584e1915bc8de342

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

<script lang="ts">
  import { Link, type InertiaForm } from '@inertiajs/svelte'
  import type { <%= inertia_model_type %>, <%= inertia_model_form_type %> } from './types'
  import Form from './Form.svelte'

  export let <%= singular_table_name %>: <%= inertia_model_type %>

  const handleSubmit = (e: CustomEvent<{ form: InertiaForm<<%= inertia_model_form_type %>> }>) => {
    const { form } = e.detail
    form.transform((data) => ({ <%= singular_table_name %>: data }))
<% if attributes.any?(&:attachments?) -%>
    form.post(`<%= js_resource_path %>`, {
      headers: { 'X-HTTP-METHOD-OVERRIDE': 'put' },
    })
<% else -%>
    form.patch(`<%= js_resource_path %>`)
<% end -%>
  }
</script>

<svelte:head>
  <title>Editing <%= human_name.downcase %></title>
</svelte:head>

<h1>Editing <%= human_name.downcase %></h1>

<Form
  {<%= singular_table_name %>}
  submitText="Update <%= human_name %>"
  on:submit={handleSubmit}
/>

<br />

<div>
  <Link href={`<%= js_resource_path %>`}>Show this <%= human_name.downcase %></Link> |
  <Link href="<%= js_resources_path %>">Back to <%= human_name.pluralize.downcase %></Link>
</div>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
inertia_rails-3.5.0 lib/generators/inertia_templates/scaffold/templates/svelte4/Edit.ts.svelte.tt