#ModalContent inputs pass to action()

11 messages · Page 1 of 1 (latest)

smoky ruin
#

BulkAction use modalContent custom view blade with inputs - how to pass input values to action after confirm modalDialog?

pure shale
smoky ruin
#

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'),

pure shale
# smoky ruin

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);
})
smoky ruin
#

Can I use it in Resource file?

pure shale
smoky ruin
#

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 🙂

pure shale
smoky ruin
#

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'];
                        }
                    })