F
Filamentharitz

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.
->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: ```php Tables\Actions\Action::make('test') ->form([ TextInput::make('name')->reactive(),...
haritz
haritz8d ago
Any idea how I can do this?
Patrick Boivin
Patrick Boivin8d ago
It's not completely clear what you're trying to do... Can you maybe share a screenshot?
haritz
haritz8d ago
When I click the action, open the next modal. When I click the send button, I want to open an url with the data of the from. I get the data but I need to open theurl. Hope I explained well
No description
haritz
haritz8d ago
No description
Patrick Boivin
Patrick Boivin8d ago
One way to open a URL would be with a link. You can change the Send button into a link.
haritz
haritz8d ago
But how could I get the message contetn? The send button is rendered once the modal is open
Patrick Boivin
Patrick Boivin8d ago
If your fields are reactive() or lazy(), the button will re-render.
Solution
Patrick Boivin
Patrick Boivin8d ago
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'] ?? ''));
}),
haritz
haritz8d ago
Worked perfectly. Thank you very much.
Want results from more Discord servers?
Add your server
More Posts
How to change color palette dynamicallyMy application is multitenant and I would like to change the color palettes according to the client,Custom ValidationMessages for minDate/maxDateI have tried the following, but the html5 validation still shows the default browser error. Do i neeModal actionHow can I do this in a modal window, since there is no ->columns() optionRepeater and auto-increment fieldI have a form with a repeater and I have a field for the number of the element. I want that field tBuild not picking up my Theme CSSI've added this plugin https://filamentphp.com/plugins/mokhosh-kanban and I'm updating the card viewMarkdownEditor not recognising inputI have a Form with a Markdown Editor, it is a required field. When I enter some text and try to savCustom Save Button for Create/Edit with Disable on FileUploadHello Filament Friends, I have a problem with implementing different Save Buttons. My process shoulImage Gallery On Modal like ImageColumnI have to make an image selector to which I pass a collection like this ImageProduct::all() where How can I add fields to / extend a resource from a pluginI want to add a form field to an existing module/plugin we are using. I already tried extending the I can't land home page.When I install the database and try to land homepage, I fails.Attachments concept tipsHello everyone, this is my first post so sorry if I make some mistakes. I've some entities that haveIs it possible to have tabs that look like sub-navigation?I want to have an edit page where I can change form by tabs that have the styling from sub-navigatioHow I can enable the Relation Manager Action in view mode?Normally, it is new action button is seen when it is in Edit mode. For user experience I would like Connecting the media library with entities?I have a resource for product reviews that lists review, each review might have some images with it.Custom BulkActionHi guys, newbie here... in a table i would like to pass the selected record to a controller and thenCallback on resource creation in modalHi, I'm creating a resource and rather than using a dedicated create page I'm using a modal window. Multiple Select that creates on submitI have a Select in a form that allows users to attach Skill resources to themselves. ``` Select::makNotifications Markup not working as expected?I'm using this and getting this: ` Notification::make() ->title('Summer SHeader action on section to go back on a specific step on a Wizard FormHello, I was wondering if it was possible, in a Wizard Form, to have a button that would allow you tModal Action inside Slideover [BUG]I have issue when I click modal inside Slideover , the page hangs . Would it be possible to achiev