@maticl
@maticl
FFilament
Created by @maticl on 2/5/2025 in #❓┊help
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()
]);
4 replies
FFilament
Created by @maticl on 2/5/2025 in #❓┊help
Table action with form - confirmation before submit
Hello, I am trying to add confirmation (or any kind of modal action) when user clicks submit on a table action with a form. I have tried with extraModalFooterActions, that contains requiresConfirmation(), which when clicked does show the confirmation (but closes the parent modal, i thought it just displays over it?), but then cancelParentActions() doesn't work, reopening the parent modal again. Code for extraModalFooterActions:
use Filament\Tables\Actions\Action;
$this->extraModalFooterActions([
Action::make('confirm')
->requiresConfirmation()
->action(function ($record) {
$this->cancelParentActions();
\Log::debug('confirmed');
})
]);
use Filament\Tables\Actions\Action;
$this->extraModalFooterActions([
Action::make('confirm')
->requiresConfirmation()
->action(function ($record) {
$this->cancelParentActions();
\Log::debug('confirmed');
})
]);
Has anyone had similar issues, and if so how did you resolve it?
6 replies
FFilament
Created by @maticl on 11/8/2024 in #❓┊help
RelationManager table action always injects the same record
What I am trying to do: On a relation manager I have a table action, that displays audit log details. Not all audit logs have details view, so I dynamically resolve content and visibility based on audit log class. If you need any more context feel free to ask. What I did: I cleared every cache, debugged it, everything seems fine except the injection. If I log the record in modalContent callback, it always points to the record of the first row in the table (even if we go to page 2, it will point to the record of first row on page 1). The developer tools network logs dispatch the correct events with correct ids. log_instance is an Attribute on AuditLog model, that resolves the audit type class with all the data. My issue/the error: For some reason, the action modalContent and modalWidth callbacks always get injected with the same record (model of the first row in the table). Visibility callback works okay. Code:
use Filament\Tables\Actions\Action;

...

->actions([
Action::make('view-log')
->modalSubmitActionLabel('Close')
->modalCancelAction(false)
->modalFooterActionsAlignment('end')
->modalContent(function (AuditLog $record) {
if (!$record->log_instance instanceof HasTableViewAction) {
return view();
}
return view(
$record->log_instance->getActionView(),
['auditLog' => $record]
);
})
->modalWidth(function (AuditLog $record) {
if (!$record->log_instance instanceof HasTableViewAction) {
return 'md';
}

return $record->log_instance->getModalWidth();
})
->hidden(fn (AuditLog $record): bool => !($record->log_instance instanceof HasTableViewAction))

])
use Filament\Tables\Actions\Action;

...

->actions([
Action::make('view-log')
->modalSubmitActionLabel('Close')
->modalCancelAction(false)
->modalFooterActionsAlignment('end')
->modalContent(function (AuditLog $record) {
if (!$record->log_instance instanceof HasTableViewAction) {
return view();
}
return view(
$record->log_instance->getActionView(),
['auditLog' => $record]
);
})
->modalWidth(function (AuditLog $record) {
if (!$record->log_instance instanceof HasTableViewAction) {
return 'md';
}

return $record->log_instance->getModalWidth();
})
->hidden(fn (AuditLog $record): bool => !($record->log_instance instanceof HasTableViewAction))

])
3 replies