Add Action to Select modal create and update

I have a form with a Template entity and a Select field for the Sender entity which is a table with SMTP data for sending emails. The Sender field is defined like this:
Select::make('sender')
->label(__('From'))
->relationship('sender', 'name')
->searchable()
->preload()
->createOptionForm(Sender::getFormSchema())
->editOptionForm(Sender::getFormSchema())
Select::make('sender')
->label(__('From'))
->relationship('sender', 'name')
->searchable()
->preload()
->createOptionForm(Sender::getFormSchema())
->editOptionForm(Sender::getFormSchema())
But I would like to add to the Actions of the modal a TEST CONFIG button to test the configuration. The problem is that I don't see how to add this Action to the modal from the Select. Any idea?
Solution:
maybe you could use a form action in the getFormSchema, like: ```php use Filament\Forms\Components\Actions; ...
Jump to solution
5 Replies
Roberto S.
Roberto S.OP2mo ago
Thanks Matthew, I had already read that documentation but my problem is that in the Select I can't add the registerModalActions(). I don't know if there is a way to do it from this field.
Matthew
Matthew2mo ago
Not clear on exactly what you are trying to achieve...a screenshot would help
Solution
LeandroFerreira
LeandroFerreira2mo ago
maybe you could use a form action in the getFormSchema, like:
use Filament\Forms\Components\Actions;

...
->createOptionForm([

TextInput::make('host'),
//other fields...

Actions::make([
Actions\Action::make('test_config')
->action(function (Get $get) {
//you can get the form values using $get('host'), $get('port') etc.
}),
]),
])
use Filament\Forms\Components\Actions;

...
->createOptionForm([

TextInput::make('host'),
//other fields...

Actions::make([
Actions\Action::make('test_config')
->action(function (Get $get) {
//you can get the form values using $get('host'), $get('port') etc.
}),
]),
])
Roberto S.
Roberto S.OP2mo ago
Great! Thanks Leandro!
Want results from more Discord servers?
Add your server