Launch one table action from the createAction

Hi, Can anyone help point me in the right direction of launching a table action from the completion of a CreateAction. Dependent on the outocome of the entry, and the specifics of the data entered, I would like it to write the row, and then launch straight into a table action for that row. Thanks
Solution:
maybe ```php Actions\CreateAction::make() ->after(function (YourModel $record) {...
Jump to solution
10 Replies
Matthew
MatthewOP2mo ago
bump Anyone ? Still struggling with this.....
Rolland
Rolland2mo ago
could you explain a bit more? kinda hard to understand your 1st explanation. thank you..
awcodes
awcodes2mo ago
Not sure exactly what you are trying to do, but maybe this will help: https://filamentphp.com/docs/3.x/actions/adding-an-action-to-a-livewire-component#chaining-actions
Matthew
MatthewOP4w ago
I suppose it could be simplified to this: If I've got a CreateAction, that makes a new row...how can I immediately launch a TableAction on that new row ? bump
Solution
LeandroFerreira
maybe
Actions\CreateAction::make()
->after(function (YourModel $record) {
$this->mountTableAction('edit', $record->id);
})
Actions\CreateAction::make()
->after(function (YourModel $record) {
$this->mountTableAction('edit', $record->id);
})
Matthew
MatthewOP4w ago
Nope. Unfortunately not working. A dd of the command returns null. Any other suggestions very gratefully received. This doesn't feel like an edge case use ?
LeandroFerreira
you mean, dd($record) returns null?
Matthew
MatthewOP4w ago
Ahh....actually it does work. But, I was using a form filler that as well as filling the slideover form also populates the searhc box in the table behind. So, when it was being called, the newly created record was already filtered out, and thus didn't fire. In the real world, people won't be using form fillers, but it could be the case they will have filtered the table for something else, beofre they then decide to create new one.... Can I clear the filter and search as part of the Create Action ?
Matthew
MatthewOP4w ago
resetTable didn't seem to work, but I tried some other methods, and decided on a kitchen sink approach, with a notification to blame the user's browser.
->before(function () {
$this->resetTable();
$this->resetTableSearch();
$this->resetTableFiltersForm();
})
->after(function (Reference $record, array $data) {

if (Arr::get($data, 'chooseAction', '') === 'newRequest') {

$this->mountTableAction('sendRequest', $record->rf_id);

NotificationItem::success(
title: 'Reference Request started',
body: 'new reference screen should now be open, if not it is your browsers fault etc..',
seconds: 10
);

}
}),
->before(function () {
$this->resetTable();
$this->resetTableSearch();
$this->resetTableFiltersForm();
})
->after(function (Reference $record, array $data) {

if (Arr::get($data, 'chooseAction', '') === 'newRequest') {

$this->mountTableAction('sendRequest', $record->rf_id);

NotificationItem::success(
title: 'Reference Request started',
body: 'new reference screen should now be open, if not it is your browsers fault etc..',
seconds: 10
);

}
}),
So that is working to an acceptable level. Many thanks for your help. I was almost resigned to a lot of form duplication and intricate wizards !

Did you find this page helpful?