#ModalContent inputs pass to action()
11 messages · Page 1 of 1 (latest)
why not using ->form()?
BulkAction::make('customAction')
->form([
TextInput::make('field')
])
->action(function (array $data, Collection $records) {
dd($data, $records);
})
I've tried wire:model etc. but dont work
BulkAction::make('group_wise_transfer')
->action(function (BulkAction $action, Collection $records, array $data) {
dump($action->getModalContent()->getData());
dump($data);
Notification::make()
->title("Utalás elindítva: " . count($records) . " db számla")
->duration(5000)
->success()
->send();
})
->label('Csoportos utalás')
->requiresConfirmation()
->modalWidth('5xl') // Set custom modal width
->modalContent(function (Collection $records): View {
// CUSTOM LOGIC GOES HERE
return view('filament.pages.wise-group-modal', ['all_fee' => $allTransferFee, 'all_gross' => $allGross, 'records' => $toFunding, 'existing' => null]);
})
->color('primary')
->icon('heroicon-s-arrow-right'),
add public $notes = []; to your ListPage
inject $livewire in the action:
->action(function (BulkAction $action, Collection $records, array $data, Pages\YourListPage $livewire) {
dd($livewire->notes);
})
Can I use it in Resource file?
no, because your ListPage is the livewire component. What is the problem to add this to your ListPage?
Thank you it works!
Only one thing - the values dont be filled in this step:
<input class="..." wire:model.defer="notes.{{ $key }}" type="text" value="{{ $record['notes'] }}">
livewire and value dont love each other 🙂
use mountUsing to fill $notes
BulkAction::make('group_wise_transfer')
->mountUsing(function (Pages\YourListPage $livewire) {
$livewire->notes = ['xxx', 'yyy'];
})
...
Thank you @pure shale you saved my day. Everíthing working now.
->mountUsing(function (BulkAction $action, ListAdminInvoices $livewire) {
foreach ($action->getModalContent()->getData()['records'] as $value) {
$livewire->notes[] = $value['notes'];
}
})