replaceMountedAction
How to use
replaceMountedAction
on resource?Solution:Jump to solution
I think you need to add the sendMoneyConfirmation method to the ListPage
```php
->headerActions([
Tables\Actions\Action::make('sendMoney')...
7 Replies
->headerActions([
Tables\Actions\Action::make('send_money')
->label('Send Money')
->form([
TextInput::make('username')
->label('Send money to')
->placeholder('Type username')
->required()
->lazy()
->maxLength(255)
->afterStateUpdated(function (SendMoneyAction $send_money_action, $state) {
$send_money_action->search($state);
}),
TextInput::make('amount')
->required()
->numeric()
->minValue(1)
->maxValue(auth()->user()->getBalance()),
])
->registerModalActions([
Action::make('send_money_confirmation')
->mountUsing(function () {
dd('test');
})
->requiresConfirmation()
->action(function () {
})
])
->action(function (SendMoneyAction $send_money_action, $action, array $data, $livewire) {
$livewire->replaceMountedAction('send_money_confirmation');
})
->modalHeading('Send Money To Any Distributor')
->modalSubmitActionLabel('Send Money')
])
->headerActions([
Tables\Actions\Action::make('send_money')
->label('Send Money')
->form([
TextInput::make('username')
->label('Send money to')
->placeholder('Type username')
->required()
->lazy()
->maxLength(255)
->afterStateUpdated(function (SendMoneyAction $send_money_action, $state) {
$send_money_action->search($state);
}),
TextInput::make('amount')
->required()
->numeric()
->minValue(1)
->maxValue(auth()->user()->getBalance()),
])
->registerModalActions([
Action::make('send_money_confirmation')
->mountUsing(function () {
dd('test');
})
->requiresConfirmation()
->action(function () {
})
])
->action(function (SendMoneyAction $send_money_action, $action, array $data, $livewire) {
$livewire->replaceMountedAction('send_money_confirmation');
})
->modalHeading('Send Money To Any Distributor')
->modalSubmitActionLabel('Send Money')
])
Solution
I think you need to add the sendMoneyConfirmation method to the ListPage
ListXX.php
->headerActions([
Tables\Actions\Action::make('sendMoney')
->form([
//...
TextInput::make('amount'),
])
->action(function (array $data, array $arguments, Page $livewire) {
$livewire->replaceMountedAction('sendMoneyConfirmation');
}),
])
->headerActions([
Tables\Actions\Action::make('sendMoney')
->form([
//...
TextInput::make('amount'),
])
->action(function (array $data, array $arguments, Page $livewire) {
$livewire->replaceMountedAction('sendMoneyConfirmation');
}),
])
public function sendMoneyConfirmationAction(): Action
{
return Action::make('sendMoneyConfirmation')
->requiresConfirmation()
->action(function (array $arguments) {
//...
});
}
public function sendMoneyConfirmationAction(): Action
{
return Action::make('sendMoneyConfirmation')
->requiresConfirmation()
->action(function (array $arguments) {
//...
});
}
public function sendMoneyConfirmationAction(): Action
{
return Action::make('send_money_confirmation')
->requiresConfirmation()
->action(function (array $arguments) {
//...
});
}
public function sendMoneyConfirmationAction(): Action
{
return Action::make('send_money_confirmation')
->requiresConfirmation()
->action(function (array $arguments) {
//...
});
}
public function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('reference_number')
->searchable()
->sortable(),
TextColumn::make('amount')
->money('PHP')
->color(fn ($state) => $state > 0 ? 'success' : 'danger')
->sortable(),
TextColumn::make('created_at')
->label('Transaction date')
->dateTime()
->sortable(),
TextColumn::make('notes'),
])
->headerActions([
Action::make('send_money')
->label('Send Money')
->form([
TextInput::make('username')
->label('Send money to')
->placeholder('Type username')
->required()
->maxLength(255),
TextInput::make('amount')
->required()
->numeric()
->minValue(1)
->maxValue(auth()->user()->getBalance()),
])
->action(function (SendMoneyAction $send_money_action, $action, array $data, Page $livewire) {
$livewire->replaceMountedAction('send_money_confirmation');
})
->modalHeading('Send Money To Any Distributor')
->modalSubmitActionLabel('Send Money')
])
->defaultSort('created_at', 'desc');
}
public function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('reference_number')
->searchable()
->sortable(),
TextColumn::make('amount')
->money('PHP')
->color(fn ($state) => $state > 0 ? 'success' : 'danger')
->sortable(),
TextColumn::make('created_at')
->label('Transaction date')
->dateTime()
->sortable(),
TextColumn::make('notes'),
])
->headerActions([
Action::make('send_money')
->label('Send Money')
->form([
TextInput::make('username')
->label('Send money to')
->placeholder('Type username')
->required()
->maxLength(255),
TextInput::make('amount')
->required()
->numeric()
->minValue(1)
->maxValue(auth()->user()->getBalance()),
])
->action(function (SendMoneyAction $send_money_action, $action, array $data, Page $livewire) {
$livewire->replaceMountedAction('send_money_confirmation');
})
->modalHeading('Send Money To Any Distributor')
->modalSubmitActionLabel('Send Money')
])
->defaultSort('created_at', 'desc');
}
use Filament\Forms\Components\TextInput;
use Filament\Pages\Page;
use Filament\Resources\Pages\ListRecords;
use Filament\Tables\Actions\Action;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Filament\Forms\Components\TextInput;
use Filament\Pages\Page;
use Filament\Resources\Pages\ListRecords;
use Filament\Tables\Actions\Action;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
does it work?
about this.. nope.. it didn't work..
maybe you could try exactly my code... it works
sorry for the late reply.. yes it worked!
send_money_confirmation
will not work.. it should be in camel case