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