Marek
Marek
FFilament
Created by Marek on 5/9/2025 in #❓┊help
Filling data in custom forms on a custom page does not work
I am trying to have two forms on a custom page for a resource. Neither of forms is attached to the model. I am unable to populate the form with data. It just doesn't do anything. Here's what I've done:
class TakePaymentPage extends Page
{
// ...

protected function getForms(): array
{
return [
'manualPaymentForm',
'stripePaymentForm',
];
}

public function manualPaymentForm(Form $form): Form
{
return $form
->schema([
Section::make('Manual Payment')
->columns(2)
->schema([
TextInput::make('customer_name')
->label('Customer'),
TextInput::make('customer_email')
->label('Email'),
TextInput::make('reference'),
]),
])
->fill([
'customer_name' => $this->record->customer->fullName(),
'customer_email' => $this->record->customer->email,
])
;
}
}
class TakePaymentPage extends Page
{
// ...

protected function getForms(): array
{
return [
'manualPaymentForm',
'stripePaymentForm',
];
}

public function manualPaymentForm(Form $form): Form
{
return $form
->schema([
Section::make('Manual Payment')
->columns(2)
->schema([
TextInput::make('customer_name')
->label('Customer'),
TextInput::make('customer_email')
->label('Email'),
TextInput::make('reference'),
]),
])
->fill([
'customer_name' => $this->record->customer->fullName(),
'customer_email' => $this->record->customer->email,
])
;
}
}
I've checked, when method is executed, $this->record is populated, if I do dd($form) in that method, it seems form has the details. But when page is rendered, the details are not populated. What am I doing wrong?
13 replies
FFilament
Created by Marek on 5/8/2025 in #❓┊help
Route not found for Filament Resource Page
I'm an experienced PHP/Symfony developer, my experience with Laravel and Filament is very limited. I apologise in advance for a trivial question. I created a new Resource, with two pages: index, and issue. Autodiscovery seems to work fine, when I run the route:list command from the command line, I see the routes:
$ php artisan route:list | grep premiums
GET|HEAD admin/premiums ................................ filament.app.resources.premiums.index › App\Filament\Resources\PremiumResource\Pages\ListPremiums
GET|HEAD admin/premiums/{record}/issue ................. filament.app.resources.premiums.issue › App\Filament\Resources\PremiumResource\Pages\IssuePremium
$ php artisan route:list | grep premiums
GET|HEAD admin/premiums ................................ filament.app.resources.premiums.index › App\Filament\Resources\PremiumResource\Pages\ListPremiums
GET|HEAD admin/premiums/{record}/issue ................. filament.app.resources.premiums.issue › App\Filament\Resources\PremiumResource\Pages\IssuePremium
When I try to use the route in Filament's Action, I get the following error:
Internal Server Error

Symfony\Component\Routing\Exception\RouteNotFoundException
Route [filament.app.resources.premiums.issue] not defined.
Internal Server Error

Symfony\Component\Routing\Exception\RouteNotFoundException
Route [filament.app.resources.premiums.issue] not defined.
Well, clearly it's defined, as route:list lists that route... so not sure what is going on here. I have tried clearing cache, restarting the app, even restarted my PC. The relevant PHP code that tries to use the route is:
->actions([
Action::make('premiums.issue')
->label('Issue')
->url(fn (Premium $p) => route('filament.app.resources.premiums.issue', ['record' => $p->id]))
,
])
->actions([
Action::make('premiums.issue')
->label('Issue')
->url(fn (Premium $p) => route('filament.app.resources.premiums.issue', ['record' => $p->id]))
,
])
PremiumResource class:
final class PremiumResource extends Resource
{
protected static ?string $model = Premium::class;

protected static ?string $navigationGroup = null;
protected static ?int $navigationSort = null;

public static function getPages(): array
{
return [
'index' => Pages\ListPremiums::route('/'),
'issue' => Pages\IssuePremium::route('/{record}/issue'),
];
}
}
final class PremiumResource extends Resource
{
protected static ?string $model = Premium::class;

protected static ?string $navigationGroup = null;
protected static ?int $navigationSort = null;

public static function getPages(): array
{
return [
'index' => Pages\ListPremiums::route('/'),
'issue' => Pages\IssuePremium::route('/{record}/issue'),
];
}
}
ListPremiums extends ListRecords, while IssuePremium extends EditRecord. Thank you.
33 replies
FFilament
Created by Marek on 4/8/2025 in #❓┊help
Simple question about nested models with Form
Hello, This is my first time using Filament, so please be gentle with me. I've tried to find a solution on-line, including asking AI, but I cannot figure out what I am doing wrong. I got three models: Child, Parent, and Grandparent. Child belongs to Parent, Parent belongs to Grandparent. I would like to display, on the Child view page, values from both Parent and Grandparent. In the form builder I have tried to access their values using dot notation, so it looks like this:
Section::make('Child')
->schema([
TextInput::make('name'),
TextInput::make('parent.name')->label('Parent'),
TextInput::make('parent.grandparent.name')->label('Grandparent'),
])
Section::make('Child')
->schema([
TextInput::make('name'),
TextInput::make('parent.name')->label('Parent'),
TextInput::make('parent.grandparent.name')->label('Grandparent'),
])
Unfortunately, neither parent.name nor parent.grandparent.name values are being populated. I have overloaded ViewRecord::mount() to check if record is populated correctly - it is. I have tried to use ->state(fn (Child $record) => $record->parent->name) to set the value, but this throws an exception about accessing uninitialised $container. Is there a way to build a view page that does not look like a form? I have some resources (or part of resources) I would like to view and never edit. Any help/pointers will be appreciated. Kind regards, Marek
8 replies