Skip to main content

Edit Form and Breadcrumbs

Premium
6 min read

Now, let's build the page to edit the task. It will be structurally similar to the Create form but with a few differences.

Also, at the end of this lesson, we will add breadcrumbs above the table.


Table: Link to Edit Route

We need to add the "Edit" button to the table.

{tasks.map((task) => (
<TableRow key={task.id}>
 
// ...
 
<TableCell className="flex flex-row gap-x-2 text-right">
 
<Link className={buttonVariants({ variant: 'default' })}
href={`/tasks/${task.id}/edit`}>
Edit
</Link>
 
<Button variant={'destructive'} className={'cursor-pointer'}
onClick={() => deleteTask(task.id)}>
Delete
</Button>
</TableCell>
</TableRow>
))}

Here's the visual result:


Edit Page: React Component

The previous code snippet above shows the URL /tasks/${task.id}/edit. This corresponds to the Controller method edit(), which uses Route Model Binding to find the task.

app/Http/Controllers/TaskController.php

public function edit(Task $task)
{
return Inertia::render('Tasks/Edit', [
'task' => $task,
]);
}

Now, we need to create the..

The Full Lesson is Only for Premium Members

Want to access all of our courses? (30 h 41 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

SP
Steve Popoola ✓ Link copied!

Hi,

Just a small typo in the tutorial. In the breadcrumbs section for create:

const breadcrumbs: BreadcrumbItem[] = [
{ title: 'Dashboard', href: '/dashboard' },
{ title: 'Tasks', href: '/tasks' },
{ title: 'Create', href: '/tasks' },
];

The href for 'Create' should be to an empty string { title: 'Create', href: ' ' },

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.