Pass data from parent modal to child

Hello, I have a usecase where I want to alert user that a specific action will dispatch unreversable data changes, and he needs to confirm it. For example, a specific department has N services with external role (for example admin on it). User goes to change the role on a specific service in the department via table action. When he submits the form, we want to show which users will be affected by this change (tickets will be opened to change the role on the service) and he has to confirm. To implement this, I need the newly selected role from parent model. If I inject data argument into action() method, it's always empty. Code for action:
$this->modalFooterActions([
Action::make('submit')
->form([
// some display data here (maybe should use infolist)
])
->fillForm(function (array $data) {
// Need parent data here
})
->modalWidth('md')
->cancelParentActions()
->action(function (array $data) {
// Execute the action here
}),
$this->getModalCancelAction()
]);
$this->modalFooterActions([
Action::make('submit')
->form([
// some display data here (maybe should use infolist)
])
->fillForm(function (array $data) {
// Need parent data here
})
->modalWidth('md')
->cancelParentActions()
->action(function (array $data) {
// Execute the action here
}),
$this->getModalCancelAction()
]);
Solution:
Figured out you can get it from mountedtableactions: ```php ->fillForm(function (Component $livewire) { dd($livewire->mountedTableActionsData[0]); // Need parent data here...
Jump to solution
1 Reply
Solution
@maticl
@maticl3w ago
Figured out you can get it from mountedtableactions:
->fillForm(function (Component $livewire) {
dd($livewire->mountedTableActionsData[0]);
// Need parent data here
})
->fillForm(function (Component $livewire) {
dd($livewire->mountedTableActionsData[0]);
// Need parent data here
})

Did you find this page helpful?