F
Filament7mo 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(),
]);
}

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.
No description
Solution:
never mind. i was missing create action inside list resource ```php <?php ...
Jump to solution
3 Replies
ChesterS
ChesterS7mo ago
What do you mean? It is on top of the table. Or do you only want to show the 'Add unit ' if the table is empty?
Solution
Jaw
Jaw7mo ago
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
];
}
}
<?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
];
}
}
Jaw
Jaw7mo ago
No description