F
Filamentβ€’2y ago
Husky110

Problems with Modelbinding

Hey - I ain't sure if this is a Livewire, Laravel, or Filament-thing, but hopefully this thing is common enough so someone has an idea... I am trying to pass data from one form-page to the next. What I did so far is to build the submit-method on the first page like this: return redirect(Detailselection::getUrl(['article' => $this->article]));and altered the mount-method on the Detailselection-Page like this:
public function mount(TypedArticle $article): void
{
$this->typedArticle = $article;
$this->form->fill();
}
public function mount(TypedArticle $article): void
{
$this->typedArticle = $article;
$this->form->fill();
}
now when I add a dd($article)to the mount-method, I get an empty TypedArticle-model-instance, even tho the URL looks like this: .../detailselection?article=2 (which should load the TypedArticle-Model with ID 2). What am I missing here?
6 Replies
Dan Harrin
Dan Harrinβ€’2y ago
public TypedArticle $article, you shouldnt need to have a parameter on mount()
Husky110
Husky110OPβ€’2y ago
I thought so aswell, but removing it results in Typed property App\Filament\Pages\...\Detailselection::$article must not be accessed before initialization
Dan Harrin
Dan Harrinβ€’2y ago
oh i know why article is not a url parameter, its a query parameter if you want to use a query parameter, you need to TypedArticle::find(request()->query('article'))
Husky110
Husky110OPβ€’2y ago
Ah okay - and how would I pass it as an URL-Parameter? Cause I did what was posted at https://laravel-livewire.com/docs/2.x/rendering-components#parameters but the $article-Parameter inside the mount-function is empty (as stated).
Livewire
Rendering Components | Livewire
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
Dan Harrin
Dan Harrinβ€’2y ago
on the Detailselection class, $slug = 'detailselection/{article}'
Husky110
Husky110OPβ€’2y ago
Best man! Thank you! πŸ™‚
Want results from more Discord servers?
Add your server