Sha256: 35e5c2286ce7e06075d5a7d4a72c8a469b4fa339af0dee9b497307c1861467f6

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

<script>
  import { Link } from '@inertiajs/svelte'
  import Form from './Form.svelte'

  let { <%= singular_table_name %> } = $props()

  const handleSubmit = ({ form }) => {
    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>

<div class="mx-auto md:w-2/3 w-full px-8 pt-8">
  <h1 class="font-bold text-4xl">Editing <%= human_name.downcase %></h1>

  <Form
    {<%= singular_table_name %>}
    submitText="Update <%= human_name %>"
    onSubmit={handleSubmit}
  />

  <Link
    href={`<%= js_resource_path %>`}
    class="mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
  >
    Show this <%= human_name.downcase %>
  </Link>
  <Link
    href="<%= js_resources_path %>"
    class="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
  >
    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_tw_templates/scaffold/templates/svelte/Edit.svelte.tt