how to get data in action child from action parent?

I need data form Action parent_action in Action child child_action modalContent().
Actions\Action::make('parent_action')
->form([
Forms\Components\Select::make('wallet_id'),
Forms\Components\DatePicker::make('start_transaction_at'),
Forms\Components\DatePicker::make('end_transaction_at'),
])
->extraModalFooterActions(fn ($action, $arguments, $data): array => [
Actions\Action::make('child_action')
->modal()
->modalContent(
function ($record, $livewire) use ($action, $arguments, $data) {
dd([$data, $record, $livewire, $arguments, $action]);
$object = '...';
return str($object)->toHtmlString();
}
)
])
->modalSubmitAction(false),
Actions\Action::make('parent_action')
->form([
Forms\Components\Select::make('wallet_id'),
Forms\Components\DatePicker::make('start_transaction_at'),
Forms\Components\DatePicker::make('end_transaction_at'),
])
->extraModalFooterActions(fn ($action, $arguments, $data): array => [
Actions\Action::make('child_action')
->modal()
->modalContent(
function ($record, $livewire) use ($action, $arguments, $data) {
dd([$data, $record, $livewire, $arguments, $action]);
$object = '...';
return str($object)->toHtmlString();
}
)
])
->modalSubmitAction(false),
2 Replies
Kaesa Lyrih
Kaesa LyrihOP7mo ago
dd([$data, $record, $livewire, $arguments, $action]);
// result:
// $data = [],
// $record = null,
// $livewire = ManageTransaciton::class
// $arguments = [],
// $action = Action::class
dd([$data, $record, $livewire, $arguments, $action]);
// result:
// $data = [],
// $record = null,
// $livewire = ManageTransaciton::class
// $arguments = [],
// $action = Action::class
How to get data form Action parent_action to child Action child_action modalContent()? I temp solve using $livewire->mountedActionsData[0] to get data action perent, any other solution?
Action::make('child_action')
->modal()
->modalContent(function ($record, $livewire) use ($action, $arguments, $data) {
dd([
$data,
$record,
$livewire->mountedActionsData[0],
$arguments,
$action
]);
$object = '...';
return str($object)->toHtmlString();
}),
Action::make('child_action')
->modal()
->modalContent(function ($record, $livewire) use ($action, $arguments, $data) {
dd([
$data,
$record,
$livewire->mountedActionsData[0],
$arguments,
$action
]);
$object = '...';
return str($object)->toHtmlString();
}),
problem, validated form data not work in extraModalFooterActions, humm.
Kaesa Lyrih
Kaesa LyrihOP7mo ago
My study case, solve with action chanining. https://filamentphp.com/docs/3.x/actions/adding-an-action-to-a-livewire-component#chaining-actions
class ManageFinancialTransactions extends ManageRecords
{
protected static string $resource = FinancialTransactionResource::class;

protected function getHeaderActions(): array
{
return [
Action::make('generate_report_pdf')
->model(FinancialTransaction::class)
->form([
Select::make('wallet_id'),
DatePicker::make('start_transaction_at'),
DatePicker::make('end_transaction_at'),
])
->action(function (array $data) {
$this->replaceMountedAction('viewPdf',arguments: $data);
})
];
}

public function viewPdfAction(): Action
{
return Action::make('name_action')
->modal()
->modalContent(
function ($record, $livewire, $action, $arguments, $data) {
dd([$record, $livewire, $action, $arguments, $data]);
$object = view('components.object-pdf', [
'src' => route('admin.financial-transactions.pdf', [
'filter' => $arguments
])
]);
return $object;
}
)
->slideOver()
->modalSubmitAction(false)
->modalCancelAction(false);
}
}
class ManageFinancialTransactions extends ManageRecords
{
protected static string $resource = FinancialTransactionResource::class;

protected function getHeaderActions(): array
{
return [
Action::make('generate_report_pdf')
->model(FinancialTransaction::class)
->form([
Select::make('wallet_id'),
DatePicker::make('start_transaction_at'),
DatePicker::make('end_transaction_at'),
])
->action(function (array $data) {
$this->replaceMountedAction('viewPdf',arguments: $data);
})
];
}

public function viewPdfAction(): Action
{
return Action::make('name_action')
->modal()
->modalContent(
function ($record, $livewire, $action, $arguments, $data) {
dd([$record, $livewire, $action, $arguments, $data]);
$object = view('components.object-pdf', [
'src' => route('admin.financial-transactions.pdf', [
'filter' => $arguments
])
]);
return $object;
}
)
->slideOver()
->modalSubmitAction(false)
->modalCancelAction(false);
}
}
Want results from more Discord servers?
Add your server