FilamentF
Filament3y 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(),
            ]);
    }
}



Used in page:

    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.



Why do i need a view? And what am i supposed to add into the view?
Was this page helpful?
Custom action not working - Filament