Header action modal to search API, how to show results properly?
So I have a header action which opens a modal. The modal houses a form field which allows you to search an external API. I process the results in the
->action(function (array $data) {}
method.
Now I want to loop over the results and build a nice HTML table or something so a user can pick a result. However I when I do var_dump($data); I get nothing. When I do dd($data) I see my data in a black dd() screen of course so it's there.
Any way of presenting this data to this or another modal and fire some PHP code when a user clicks a result?
16 Replies
action is handled on submitting the form and it would return title.
What you probably want is to use the wizard plugin by using ->steps() and add a step into it called 'Search' and another step 'Selection' which would be a custom livewire component populating data from step 1.
Solution
Oh that might work. Never used it before so I will read the docs. Cheers
No problem!
I could not find this in the docs but how do I pass data from one step to another?
Like I want to call
$results = $someClass->search($name);
when they complete Step1 and click NEXT and then have $results in Step 2.With closures , so you could do afterStateUpdated i.e.
Ahh ok. Will try. Tnx
Property type not supported in Livewire for property: [{}]
I have no clue where that comes from or what it means lolhttps://filamentphp.com/docs/3.x/forms/fields/custom#passing-data-to-view-fields
How would I access min and max in the view
Please provide a copy of your code.
Hmm I can access $omdb_result in the view but when I try to get $set('omdb_result', $movies); this one I get
htmlspecialchars(): Argument #1 ($string) must be of type string, Closure given
This doesn't seem to work either
Seems you cant pass data between Steps
Any idea @toeknee
viewData doesn't allow closures. You should be able to get the forms state within the view. with $getState or similar. You'll need to double check that one on the docs. I got it working a while ago but haven't done it since
So I can get the value of something in afterStateUpdated() from the previous step in the view? Cant find anything about sharing data between steps
Sorry for the delay, you can get the entire livewire data from within the view already, I think it's something like $getState which has all the data?
I am an idiot. I ran $getState but not the function $getState()
Would it be possible to then take a value from the modal and populate a form field in the original Filament Edit page with that?
Even just calling the Eloquent model and then save it from the modal would work. Like
$getRecord()->name = 'Blah'
and $getRecord()->save()
Yeah you should be able to pass them back and forth with V3 if I understand you correctly, there should be a parent action for example now
Taking another go at this. The following works and I get data in $movie. I need the
$movie['imdbid']
to be either pushed back to the Filament Edit page, or it should just directly update the model with the new value.
I just have no clue why. I tried calling a method on EditRelease.php with wire:click but that doesn't do anything.
I can access the model with $getRecord() but there is no $setRecord 😛
I am trying wire:emit now but getting Unable to call component method. Public method [$emit] not found on component
Ok I made it work by just calling a public function on the Filament EditRecord class