Create link to edit model

Hey, where can I get the route to edit a model. I tried route('islands.edit') Route [islands.edit] not defined.
10 Replies
Lara Zeus
Lara Zeus15mo ago
try ResourceName::getUrl('edit')
GeRaged | Niklas
GeRaged | NiklasOP15mo ago
Where can I set the id for the edit?
Lara Zeus
Lara Zeus15mo ago
getUrl('edit',['record'=>10])
GeRaged | Niklas
GeRaged | NiklasOP15mo ago
How can I use an Action inside a form? I want to list the relations in an edit form in a placeholder with action url
GeRaged | Niklas
GeRaged | NiklasOP15mo ago
Now I get this error Argument #1 ($component) must be of type Filament\Forms\Components\Component, Filament\Forms\Components\Actions\Action given
Lara Zeus
Lara Zeus15mo ago
ya make sure you importing use Filament\Forms\Components\Actions\Action;
GeRaged | Niklas
GeRaged | NiklasOP15mo ago
I did
<?php

namespace App\Filament\Resources\AtollResource\Pages;

use App\Filament\Resources\AtollResource;
use App\Filament\Resources\IslandResource;
use App\Models\Atoll;
use App\Models\Island;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\DeleteAction;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\Pages\EditRecord;

class EditAtoll extends EditRecord
{
protected static string $resource = AtollResource::class;

public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')
->required(),

Section::make()
->schema(fn (Atoll $record) => $record->islands()->get()->map(fn (Island $island) => Action::make($island->id)
->url(IslandResource::getUrl('edit', ['record' => $island->id])))->toArray())
]);
}

protected function getActions(): array
{
return [
DeleteAction::make(),
];
}
}
<?php

namespace App\Filament\Resources\AtollResource\Pages;

use App\Filament\Resources\AtollResource;
use App\Filament\Resources\IslandResource;
use App\Models\Atoll;
use App\Models\Island;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\DeleteAction;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\Pages\EditRecord;

class EditAtoll extends EditRecord
{
protected static string $resource = AtollResource::class;

public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')
->required(),

Section::make()
->schema(fn (Atoll $record) => $record->islands()->get()->map(fn (Island $island) => Action::make($island->id)
->url(IslandResource::getUrl('edit', ['record' => $island->id])))->toArray())
]);
}

protected function getActions(): array
{
return [
DeleteAction::make(),
];
}
}
triad
triad15mo ago
i'm getting this error too. did you solve it? i figured it out. i had to wrap the Action in an Actions component
GeRaged | Niklas
GeRaged | NiklasOP15mo ago
I made a custom filament/livewire component
Want results from more Discord servers?
Add your server