Skip to main content

Create Form with Inertia Form Helper

Premium
5 min read

The final part of this simple CRUD is Create and Edit forms. They will be similar, with a few differences. Let's start with adding a new task.


Link to Create Task Page

First, let's add a link above the table to lead to the Route for creating the task.

In the Laravel Routes, we have Route::resource('tasks', TaskController::class), so we need to link to the /tasks/create URL.

To do that in our Index.vue, we import the Link component and add this button-style link above the table.

resources/js/pages/Tasks/Index.vue

import {Head, router} from '@inertiajs/vue3';
import {Head, router, Link} from '@inertiajs/vue3';
import {Button} from '@/components/ui/button';
import {Button, buttonVariants} from '@/components/ui/button';
 
// ...
 
<Head title="Tasks List"/>
 
<div class="mt-4">
<Link
:class="buttonVariants({variant: 'outline'})" href="/tasks/create"> Create Task
</Link>
</div>
 
<Table class="mt-4">

This is the visual...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (30 h 09 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

AG
Andrey Galyamov ✓ Link copied!

Is it possible to somehow use named url in Link component, instead of hardcoding the string href="/tasks/create" ?

M
Modestas ✓ Link copied!

If you install a Vue/React plugin for ziggy, then - yes, it is possible:

https://inertiajs.com/routing

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.