F
Filament8mo ago
indra

access filter data from table action or bulk action

In a table i'm creating a bulk action with modal forms, I need to get a value from the table filter (such as from a value from a select filter) to create the modal form. How do I access these table filter values from bulk action form?
Solution:
Thank you, finally got it working with the following bulk action with custom form , getting the filter value and putting it inside a hidden field, then the other field which requires it using $get method: ```php BulkAction::make('MyAction') ->mountUsing( function(Forms\ComponentContainer $form, Table $table){ $form->fill([...
Jump to solution
3 Replies
indra
indra8mo ago
bump
Abi
Abi8mo ago
haven't tried this before, but try to inject the Table instance https://filamentphp.com/docs/3.x/tables/filters/getting-started#table-filter-utility-injection where ever you are calling the action
Solution
indra
indra8mo ago
Thank you, finally got it working with the following bulk action with custom form , getting the filter value and putting it inside a hidden field, then the other field which requires it using $get method:
BulkAction::make('MyAction')
->mountUsing( function(Forms\ComponentContainer $form, Table $table){
$form->fill([
'myHiddenField' => $table->getFilter('MyFilterName')->getState()['value'],
]);
})
->form([
Forms\Components\Hidden::make('myHiddenField'),
Forms\Components\Select::make('anotherField')
->options(function (Get $get) {
// we can use $get('myHiddenField') here
})
])
...
BulkAction::make('MyAction')
->mountUsing( function(Forms\ComponentContainer $form, Table $table){
$form->fill([
'myHiddenField' => $table->getFilter('MyFilterName')->getState()['value'],
]);
})
->form([
Forms\Components\Hidden::make('myHiddenField'),
Forms\Components\Select::make('anotherField')
->options(function (Get $get) {
// we can use $get('myHiddenField') here
})
])
...
Want results from more Discord servers?
Add your server