replaceMountedAction

How to use replaceMountedAction on resource?
Solution:
I think you need to add the sendMoneyConfirmation method to the ListPage ```php ->headerActions([ Tables\Actions\Action::make('sendMoney')...
Jump to solution
7 Replies
Eskie
EskieOP2w ago
->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')
])
anyone?
Solution
LeandroFerreira
I think you need to add the sendMoneyConfirmation method to the ListPage
->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');
}),
])
ListXX.php
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) {
//...
});
}
Eskie
EskieOP2w ago
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;
I moved them to my ListXXX.php
LeandroFerreira
does it work?
Eskie
EskieOP2w ago
about this.. nope.. it didn't work..
LeandroFerreira
maybe you could try exactly my code... it works
Eskie
EskieOP2w ago
sorry for the late reply.. yes it worked! send_money_confirmation will not work.. it should be in camel case
Want results from more Discord servers?
Add your server