F
Filament16mo ago
xy

Custom action not working

I have a custom action to create a new post which I want to use throughout my application on different pages. If i make the same action with Action::make() under my custom page's getHeaderActions, it works but when using my custom action class it doesn't:
<?php

namespace App\Filament\Actions\Posts;

use Filament\Actions\Action;
use Filament\Actions\CreateAction;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\Textarea;

class NewPost extends Action
{

protected function setUp(): void
{
$this
->label('Make post')

->form([
Textarea::make('message')
->placeholder('Message...')
->required(),
]);
}
}
<?php

namespace App\Filament\Actions\Posts;

use Filament\Actions\Action;
use Filament\Actions\CreateAction;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\Textarea;

class NewPost extends Action
{

protected function setUp(): void
{
$this
->label('Make post')

->form([
Textarea::make('message')
->placeholder('Message...')
->required(),
]);
}
}
Used in page:
protected function getHeaderActions(): array
{
return [
NewPost::make('makePost'),
];
}
protected function getHeaderActions(): array
{
return [
NewPost::make('makePost'),
];
}
Error:
Class [App\Filament\Actions\Posts\NewPost] extends [Filament\Support\Components\ViewComponent] but does not have a [$view] property defined.
Class [App\Filament\Actions\Posts\NewPost] extends [Filament\Support\Components\ViewComponent] but does not have a [$view] property defined.
Why do i need a view? And what am i supposed to add into the view?
2 Replies
Dennis Koch
Dennis Koch16mo ago
You are probably missing a parent::setUp()
xy
xyOP16mo ago
That was it, thank you!
Want results from more Discord servers?
Add your server