How use a widget table on modal?
I try create widget table and call on blade,
it works, but when close modal and open again break everything. Have this error in console:
livewire.js Uncaught Could not find Livewire component in DOM tree
Uncaught (in promise) Could not find Livewire component in DOM tree
I try this:
table:
->modalContent(function ($record) {
$uniqueId = 'analysis-' . $record->id . '-' . uniqid();
return view('filament.analist.pages.document-analysis',
[
'record' => $record,
'uniqueId' => $uniqueId
]);
})
blade:
<strong>{{ $record->question }}</strong>
@livewire('App\Filament\Analist\Widgets\ListDocumentReleases', ['record' => $record], key($uniqueId))
widget:
<?php
namespace App\Filament\Analist\Widgets;
use App\Models\Document;
use Filament\Tables;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;
class ListDocumentReleases extends BaseWidget
{
public $record;
public function table(Table $table): Table
{
return $table
->query(Document::getDocumentList($this->record))
->heading('')
->columns([
Tables\Columns\TextColumn::make('last_modify_at'),
Tables\Columns\TextColumn::make('original_name')
->label(__('Original Name'))
->icon('heroicon-o-document')
->url(fn ($record) => $record->link)
->openUrlInNewTab()
->color('gray'),
Tables\Columns\TextInputColumn::make('sed_answer')
->disabled(),
Tables\Columns\TextInputColumn::make('student_answer')
->disabled(),
Tables\Columns\TextInputColumn::make('analist_answer'),
])
->paginated(false);
}
}
14 Replies
up
Modals don’t have widgets but since widgets are just livewire components you could possible just render it in the modal view. Assuming you pass all the necessary data to it.
that's the way i'm doing, but when I close the modal and open it again, all components of the modal are frozen, and the columnInputs of widgetTable are returning empty
in the second screenshot the modal don't closes anymore
Do you have a repo you could share? Having trouble piecing it all together from the code you shared.
I can't send the repo, but I can send screenshots of the code
that is my resource where I call the view
that is my blade
and that is my widget Table
Hmm. Only thing that looks out of place to me is the ->query() that should be Model::query(). It’s the base query not the modified query.
Might possibly need a single element on the view. Ie, wrapping it all in a single Div.
I apply the fixes, but the problems stills the same...
this video explain the problem
Will have to look at it later, can’t open that attachment on my phone.
no problems, thanks a lot for all the help