F
Filament2mo ago
Ava

Section->headerActions->Select

Am I missing this documentation somewhere?
Solution:
You could create a custom action that extends a Forms\Components\Action, then it would work... ```php <?php ...
Jump to solution
10 Replies
dissto
dissto2mo ago
If you are looking for the SelectAction, yea it appears to be undocumented as of right now...
protected function getHeaderActions(): array
{
return [
Actions\SelectAction::make('test')
->options([
'hi' => 'Hello',
]),
];
}
protected function getHeaderActions(): array
{
return [
Actions\SelectAction::make('test')
->options([
'hi' => 'Hello',
]),
];
}
Ava
AvaOP2mo ago
This does not put the select in the section header
No description
dissto
dissto2mo ago
SelectAction not Select though Well, looks like the section does not support the SelectAction currently 🤔
Solution
dissto
dissto2mo ago
You could create a custom action that extends a Forms\Components\Action, then it would work...
<?php

namespace App\Actions;

use Filament\Actions\Concerns\HasSelect;
use Filament\Forms\Components\Actions\Action;

class MySelectAction extends Action
{
use HasSelect;

protected function setUp(): void
{
parent::setUp();

$this->view('filament-actions::select-action');
}
}
<?php

namespace App\Actions;

use Filament\Actions\Concerns\HasSelect;
use Filament\Forms\Components\Actions\Action;

class MySelectAction extends Action
{
use HasSelect;

protected function setUp(): void
{
parent::setUp();

$this->view('filament-actions::select-action');
}
}
Section::make()
->headerActions([
\App\Actions\MySelectAction::make('hi')
->options([
'option1' => 'Option 1',
])
])
Section::make()
->headerActions([
\App\Actions\MySelectAction::make('hi')
->options([
'option1' => 'Option 1',
])
])
dissto
dissto2mo ago
No description
Ava
AvaOP2mo ago
Sorry I am very new to this, where would I put this file? or component?
dissto
dissto2mo ago
Inside your src folder create a new folder "named" Actions. Create a new file named MySelectAction.php inside that folder. Paste the following code into MySelectAction.php
<?php

namespace App\Actions;

use Filament\Actions\Concerns\HasSelect;
use Filament\Forms\Components\Actions\Action;

class MySelectAction extends Action
{
use HasSelect;

protected function setUp(): void
{
parent::setUp();

$this->view('filament-actions::select-action');
}
}
<?php

namespace App\Actions;

use Filament\Actions\Concerns\HasSelect;
use Filament\Forms\Components\Actions\Action;

class MySelectAction extends Action
{
use HasSelect;

protected function setUp(): void
{
parent::setUp();

$this->view('filament-actions::select-action');
}
}
After that you should be able to use:
Section::make()
->headerActions([
\App\Actions\MySelectAction::make('hi')
->options([
'option1' => 'Option 1',
])
])
Section::make()
->headerActions([
\App\Actions\MySelectAction::make('hi')
->options([
'option1' => 'Option 1',
])
])
Ava
AvaOP2mo ago
And if I dont have a src folder?
dissto
dissto2mo ago
my bad...app folder...I have tested that code inside a plugin 🤓 app instead of src
Ava
AvaOP2mo ago
hehe okay, thanks. Worked beautifully @dissto - Thank you.
Want results from more Discord servers?
Add your server