Sha256: de95ba88275e4febb63dbba871af6c71687fe89aa3a90bb6e69ba8241876dee4

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

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

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

  const handleSubmit = ({ form }: { form: InertiaFormProps<<%= inertia_model_form_type %>> }) => {
    form.transform((data) => ({ <%= singular_table_name %>: data }))
    form.post('<%= js_resources_path %>')
  }
</script>

<svelte:head>
  <title>New <%= 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">New <%= human_name.downcase %></h1>

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

  <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/New.ts.svelte.tt