F
Filament14mo ago
Matthew

Possible livewire/filament bug in ->recordUrl() at table

According to the documentation user gets redirected upon clicking a row However, I get redirected as soon as I load the page, without clicking anything. Same thing happens when it's just for one column
class Dashboard extends Page implements HasForms, HasTable
{
use InteractsWithTable;
use InteractsWithForms;

public function table(Table $table): Table
{
return $table
->query(Test::query())
->deferLoading()
->striped()
->columns([
TextColumn::make('id'),
TextColumn::make('x')
->url("www.youtube.com", true),
TextColumn::make('y'),
])
->filters([
// ...
])
->actions([
// ...
])
->bulkActions([
// ...
])
->recordUrl(
fn (Model $record): string => dd($record),
);
}
protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.pages.dashboard';

protected function getHeaderActions(): array
{
return [
Action::make('Update')
->requiresConfirmation()
->color('info')
->action(function () {
//...
})
];
}
//...
}
class Dashboard extends Page implements HasForms, HasTable
{
use InteractsWithTable;
use InteractsWithForms;

public function table(Table $table): Table
{
return $table
->query(Test::query())
->deferLoading()
->striped()
->columns([
TextColumn::make('id'),
TextColumn::make('x')
->url("www.youtube.com", true),
TextColumn::make('y'),
])
->filters([
// ...
])
->actions([
// ...
])
->bulkActions([
// ...
])
->recordUrl(
fn (Model $record): string => dd($record),
);
}
protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.pages.dashboard';

protected function getHeaderActions(): array
{
return [
Action::make('Update')
->requiresConfirmation()
->color('info')
->action(function () {
//...
})
];
}
//...
}
No description
25 Replies
Matthew
MatthewOP14mo ago
I have the following JS errors
No description
awcodes
awcodes14mo ago
What’s in your logs?
Matthew
MatthewOP14mo ago
No description
awcodes
awcodes14mo ago
That would indicate that you’re missing an import or don’t have the namespace right. Probably in your panel provider.
Matthew
MatthewOP14mo ago
I need to have the @livewire() in the blade file, right?
awcodes
awcodes14mo ago
Not following you. Sorry. Unless you are loading a livewire component onto the page you wouldn’t need @liverwire at all.
Matthew
MatthewOP14mo ago
Hmm
<x-filament-panels::page>
<div>
{{ $this->table }}
</div>

</x-filament-panels::page>
<x-filament-panels::page>
<div>
{{ $this->table }}
</div>

</x-filament-panels::page>
awcodes
awcodes14mo ago
Ok so where is @livewire?
Matthew
MatthewOP14mo ago
This is my blade file, when I click on a row, I should technically be able to see the record associated with the clicked row I just removed it, xd I thought I would need @livewire('dashboard') But it cant find it
awcodes
awcodes14mo ago
Ok. Let’s take a step back. Sounds like you’re maybe confusing some methodologies. What exactly is Dashboard in your use case?
Matthew
MatthewOP14mo ago
Well its a livewire component Because its a page, and all pages are LW components
awcodes
awcodes14mo ago
I ask because filament has a concept of a dashboard which is the page a use is redirected to after login.
Matthew
MatthewOP14mo ago
ohhh, yeah this is my own Dashboard
awcodes
awcodes14mo ago
All resource pages are livewire components. A custom page is not a livewire component by default.
Matthew
MatthewOP14mo ago
No description
Matthew
MatthewOP14mo ago
I might be missing something
awcodes
awcodes14mo ago
A custom page is just a page that uses the page scaffold / blade views. So with a custom page you would have livewire components in the blade view that use forms, tables, etc. Maybe I’m wrong but in v3 I’ve never been able to add forms and tables directly to a class that extends the Page class.
Matthew
MatthewOP14mo ago
Huhh So, I should just make a liveiwre component instead of a page?
awcodes
awcodes14mo ago
Dan has even recommend adding forms and tables as a livewire component inside the page’s blade view. You still need the page. But you would create livewire components to add to the pages blade file. And those livewire components would use the forms/tables etc So the page is really just a shell. If that makes sense. I may not be explaining well. Can you give me the link to that screen shot from the docs?
Matthew
MatthewOP14mo ago
Ohh, do I need to reference the LW component in the Dashboard.php?
awcodes
awcodes14mo ago
Something feels off here. And it’s probably me that’s off. Lol. The original question isn’t making sense with what you’re saying. Not blaming you. Just in my head an automatic redirect without clicking a table row isn’t making sense to me. Something else is wrong here and I’m not sure what it is.
Matthew
MatthewOP14mo ago
Hmm. Well its late. I might find a solution in the morning 😅
awcodes
awcodes14mo ago
Yea. Sleep on it. I’m willing to help. Just not sure at the moment exactly what is going on.
Matthew
MatthewOP14mo ago
Thank you sir
<?php

namespace App\Livewire;

class DashComponent extends Component implements HasForms, HasTable
{
use InteractsWithTable;
use InteractsWithForms;

public function table(Table $table): Table
{
return $table
->query(Test::query())
->deferLoading()
->striped()
->columns([
TextColumn::make('id'),
TextColumn::make('x')
->url(fn (Bossman $record): string => dd($record)),
// ->recordUrl(
// fn (Model $record): string => route('posts.edit', ['record' => $record]),
// ),
TextColumn::make('y'),
])
->filters([
// ...
])
->actions([
// ...
])
->bulkActions([
// ...
]);
// ->recordUrl(
// fn (Model $record): string => dd($record),
// );
}


protected function getHeaderActions(): array
{

}

public function render(): View
{
return view('livewire.dash-component');
}
}
<?php

namespace App\Livewire;

class DashComponent extends Component implements HasForms, HasTable
{
use InteractsWithTable;
use InteractsWithForms;

public function table(Table $table): Table
{
return $table
->query(Test::query())
->deferLoading()
->striped()
->columns([
TextColumn::make('id'),
TextColumn::make('x')
->url(fn (Bossman $record): string => dd($record)),
// ->recordUrl(
// fn (Model $record): string => route('posts.edit', ['record' => $record]),
// ),
TextColumn::make('y'),
])
->filters([
// ...
])
->actions([
// ...
])
->bulkActions([
// ...
]);
// ->recordUrl(
// fn (Model $record): string => dd($record),
// );
}


protected function getHeaderActions(): array
{

}

public function render(): View
{
return view('livewire.dash-component');
}
}
Dashboard blade (page)
<x-filament-panels::page>
@livewire('dash-component')
</x-filament-panels::page>

<x-filament-panels::page>
@livewire('dash-component')
</x-filament-panels::page>

dash-component blade
<div>
{{$this->table}}
</div>
<div>
{{$this->table}}
</div>
I tried it this way, using Livewire and I still have the same problem
Want results from more Discord servers?
Add your server