F
Filament14mo ago

Add / Change the Display Value and Action on Form Buttons

Hello! I'm facing some issues with the default display values. I need to change the default display values and action to every buttons on the form. And I have spent a lot of time searching and have also tried implementing suggestions provided by others, but I still haven't been able to resolve the issue. Can someone help me, please? Add & Change the Default Buttom of Form
I found this page. And then I tried to add this in into my code. But it was not change anything when I press the New category button Add Extra Button
Filament\Resources\CategoryResource\Pages\ManageCategories.php
<?php

namespace App\Filament\Resources\CategoryResource\Pages;

use App\Filament\Resources\CategoryResource;
use Filament\Pages;
use Filament\Actions;
use Filament\Resources\Pages\ManageRecords;

class ManageCategories extends ManageRecords
{
protected static string $resource = CategoryResource::class;

protected function getHeaderActions(): array
{
return [
Pages\Actions\CreateAction::make(),
];
}

/**
* add these in
*/
protected function getFormActions(): array
{
return array_merge(parent::getFormActions(), [
Actions\Action::make('Clear')
->action(function () {
/*
* code the action here
*/
})
],
);
}
}
<?php

namespace App\Filament\Resources\CategoryResource\Pages;

use App\Filament\Resources\CategoryResource;
use Filament\Pages;
use Filament\Actions;
use Filament\Resources\Pages\ManageRecords;

class ManageCategories extends ManageRecords
{
protected static string $resource = CategoryResource::class;

protected function getHeaderActions(): array
{
return [
Pages\Actions\CreateAction::make(),
];
}

/**
* add these in
*/
protected function getFormActions(): array
{
return array_merge(parent::getFormActions(), [
Actions\Action::make('Clear')
->action(function () {
/*
* code the action here
*/
})
],
);
}
}
No description
2 Replies
DrByte
DrByte14mo ago
In your picture you circled "Create category", which appears to be the modal's title. I believe it's created by pulling a translatable string from the language files, and then adding the model's title. Related docs: https://filamentphp.com/docs/3.x/panels/resources/getting-started#customizing-the-model-label https://filamentphp.com/docs/3.x/panels/pages#customizing-the-page-heading
DrByte
DrByte14mo ago
Perhaps you can post your own code, too?
Want results from more Discord servers?
Add your server