Open url in modal action
Hello,
I am trying to open an url with parameters in a table modal. I want to open a modal, ask the user to write the message and then send it. So far I have the next code but I do not know how to make it work.
I am trying to open an url with parameters in a table modal. I want to open a modal, ask the user to write the message and then send it. So far I have the next code but I do not know how to make it work.
->extraModalFooterActions(fn (ActionTable $action): array => [
$action->makeModalSubmitAction('send')
->label('Send')
->icon('heroicon-o-paper-airplane')
->color('success'),
])
->action(function (array $data, array $arguments, $record, $action): void {
if ($data['message']) {
$customer = Customer::find($record->customer_id);
$message = $data['message'];
$url = 'https://api.whatsapp.com/send?phone=' . $customer->number . '&text=' . urlencode($message);
$action->url($url);
$action->openUrlInNewTab();
}
})->extraModalFooterActions(fn (ActionTable $action): array => [
$action->makeModalSubmitAction('send')
->label('Send')
->icon('heroicon-o-paper-airplane')
->color('success'),
])
->action(function (array $data, array $arguments, $record, $action): void {
if ($data['message']) {
$customer = Customer::find($record->customer_id);
$message = $data['message'];
$url = 'https://api.whatsapp.com/send?phone=' . $customer->number . '&text=' . urlencode($message);
$action->url($url);
$action->openUrlInNewTab();
}
})Solution
Try this:
Tables\Actions\Action::make('test')
->form([
TextInput::make('name')->reactive(),
])
->modalSubmitAction(function ($action, $livewire) {
$action->url('https://www.example.com/' . ($livewire->mountedTableActionsData[0]['name'] ?? ''));
}), Tables\Actions\Action::make('test')
->form([
TextInput::make('name')->reactive(),
])
->modalSubmitAction(function ($action, $livewire) {
$action->url('https://www.example.com/' . ($livewire->mountedTableActionsData[0]['name'] ?? ''));
}),