FilamentF
Filament5mo ago
o.m

How do I add another button on Resource page?

I wanted to add another button called "Form Settings" beside the "New Form" is it possible in filament?
If so how do I approach this problem?

So when I click on I get redirected to another page.

class FormResource extends Resource
{
    protected static ?string $model = FormModel::class;

    protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

public static function table(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('form_number')
                    ->label('#')
                    ->searchable(),
                Tables\Columns\TextColumn::make('name')
                    ->searchable(),
                Tables\Columns\TextColumn::make('courses_count')
                    ->label('# of Associated Courses')
                    ->counts('courses')
                    ->sortable(),
                Tables\Columns\TextColumn::make('author.name')
                    ->sortable(),
                Tables\Columns\TextColumn::make('created_at')
                    ->dateTime()
                    ->formatStateUsing(fn ($state) => \Illuminate\Support\Carbon::parse($state)->format('m/d/Y'))
                    ->sortable(),
                Tables\Columns\TextColumn::make('updated_at')
                    ->label('Last Updated')
                    ->date('F j, Y')
                    ->sortable(),

            ])->defaultSort('name', 'asc')
            ->filters([

            ])
            ->actions([
                Tables\Actions\EditAction::make(),
            ]);
    }

    public static function getRelations(): array
    {
        return [
            //
        ];
    }

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListForms::route('/'),
            'create' => Pages\CreateForm::route('/create'),
            'edit' => Pages\EditForm::route('/{record}/edit'),
        ];
    }
}
image.png
Solution
protected function getHeaderActions(): array
    {
        return [
            Actions\Action::make('formSetting')
                ->label('Form Settings')
                ->icon('heroicon-o-cog')
                ->button()
                ->url(route('filament.manage.pages.form-setting'))
                ->color('primary'),
            Actions\CreateAction::make(),
        ];
    }

Got it working, thanks!
Was this page helpful?