FilamentF
Filament3y ago
Jaw

how to place create action on top of the table?

How can i place create action on top of the table?

public static function table(Table $table): Table
{
    return $table
        ->columns([
        ])
        ->filters([
            //
        ])
        ->headerActions([
            Tables\Actions\CreateAction::make('create')
                ->label('Add Unit')
                ->icon('heroicon-o-plus-small'),
        ])
        ->actions([
            Tables\Actions\ViewAction::make(),
            Tables\Actions\EditAction::make(),
            Tables\Actions\DeleteAction::make(),
        ])
        ->bulkActions([
            Tables\Actions\BulkActionGroup::make([
                Tables\Actions\DeleteBulkAction::make(),
            ]),
        ])
        ->emptyStateActions([
            Tables\Actions\CreateAction::make(),
        ]);
}


if I remove the header action the create action button disappears.
image.png
Solution
never mind. i was missing create action inside list resource
<?php


use App\Filament\Resources\UnitResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListUnits extends ListRecords
{
    protected static string $resource = UnitResource::class;

    protected function getHeaderActions(): array
    {
        return [
            Actions\CreateAction::make(), // <-- missing this
        ];
    }
}
Was this page helpful?