F
Filament16h 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
dissto14h 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
AvaOP14h ago
This does not put the select in the section header
No description
dissto
dissto14h ago
SelectAction not Select though Well, looks like the section does not support the SelectAction currently 🤔
Solution
dissto
dissto14h 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
dissto14h ago
No description
Ava
AvaOP14h ago
Sorry I am very new to this, where would I put this file? or component?
dissto
dissto14h 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
AvaOP14h ago
And if I dont have a src folder?
dissto
dissto14h ago
my bad...app folder...I have tested that code inside a plugin 🤓 app instead of src
Ava
AvaOP13h ago
hehe okay, thanks. Worked beautifully @dissto - Thank you.
Want results from more Discord servers?
Add your server