Open Table Heading Model Action by URL

Hi all I have the need whereby when I open a URL with a specific paramter that the model would open with the Create Form inside it. I'm sure I read something like this is possible in the docs but I cannot find it again...
12 Replies
LeandroFerreira
LeandroFerreira6mo ago
could you explain what are you trying to do? Did you try some code?
David | Fortune Validator
So I have a Supplier page whereby it will show a table of invoices linked to the said supplier. I have a Create Invoice button in the table header. However sometimes I am coming directly from a page on my system which means I want the modal fro the Create Invoice to open up on page load. I can have a specific $_GET varaible to signify this but I cannot work out how to force the model to open automatically based on this. I hope that made sense? I'll be honest, im not sure where to start with code to force to open automatically. Im sure I read somewhere it was possible
LeandroFerreira
LeandroFerreira6mo ago
*modal, right? Create invoice opens a modal form?
David | Fortune Validator
correct. its the Modal I want to open automtically based off the $_GET condition
LeandroFerreira
LeandroFerreira6mo ago
you can pass ?action=create in the url
David | Fortune Validator
hmm didnt work. Does this work outside of the Panels setup? I should have said this is a Filament Table on a livewire page
/supplier/195?docket_prices_id=67298&action=create
/supplier/195?docket_prices_id=67298&action=create
its also a table heading action if that helps
->headerActions([
CreateAction::make('create')
->mountUsing(function (Form $form) {
->headerActions([
CreateAction::make('create')
->mountUsing(function (Form $form) {
LeandroFerreira
LeandroFerreira6mo ago
hum, I didn't try using a custom LW component
David | Fortune Validator
yeah sorry to complicate there
LeandroFerreira
LeandroFerreira6mo ago
let me try..
LeandroFerreira
LeandroFerreira6mo ago
try this:
use Livewire\Attributes\Url;

#[Url]
public $action = null;
use Livewire\Attributes\Url;

#[Url]
public $action = null;
in the action
->extraAttributes(fn(): array => $this->action === 'create' ? ['wire:init' => new HtmlString('mountTableAction(\'create\')')] : [])
->extraAttributes(fn(): array => $this->action === 'create' ? ['wire:init' => new HtmlString('mountTableAction(\'create\')')] : [])
David | Fortune Validator
amazing, that worked!! thank you ever so much I dont you explain a little on how that worked thanks again, I dont suppose you know why teh model autofocus on my first input field is being ignored and nothing is focused
Want results from more Discord servers?
Add your server