F
Filament13mo ago
btx

Undefined variable $table while using table builder

Following this tutorial: https://filamentphp.com/docs/2.x/tables/getting-started#preparing-your-livewire-component Im getting the error message: Undefined variable $table.
<?php

namespace App\Forms\Components\MemberPayment;

use App\Models\MemberPayment;
use Filament\Forms\Components\Component;
use Illuminate\Support\Collection;
use Filament\Tables;
use Illuminate\Contracts\View\View;

class MemberPaymentListComponent extends Component implements Tables\Contracts\HasTable {
use Tables\Concerns\InteractsWithTable;

protected string $view = 'forms.components.member-payment.member-payment-list-component';

/** @var Collection|MemberPayment[] */
protected Collection $items;

public static function make(): static {
return new static();
}

public function items(Collection $items): static {
$this->items = $items;

return $this;
}

/**
* @return Collection|MemberPayment[]
*/
public function getItems(): Collection {
return $this->items;
}
}
<?php

namespace App\Forms\Components\MemberPayment;

use App\Models\MemberPayment;
use Filament\Forms\Components\Component;
use Illuminate\Support\Collection;
use Filament\Tables;
use Illuminate\Contracts\View\View;

class MemberPaymentListComponent extends Component implements Tables\Contracts\HasTable {
use Tables\Concerns\InteractsWithTable;

protected string $view = 'forms.components.member-payment.member-payment-list-component';

/** @var Collection|MemberPayment[] */
protected Collection $items;

public static function make(): static {
return new static();
}

public function items(Collection $items): static {
$this->items = $items;

return $this;
}

/**
* @return Collection|MemberPayment[]
*/
public function getItems(): Collection {
return $this->items;
}
}
10 Replies
Dennis Koch
Dennis Koch13mo ago
Because it's $this->table
btx
btx13mo ago
Seems this has a side-effect with the view, where I want to embed the component. Im trying to render a table inside some tabs. But can not see what I am doing wrong...
Dennis Koch
Dennis Koch13mo ago
Seems like you didn't completely follow the setup instructions. Where are all the getTable...() methods?
btx
btx13mo ago
Ok, I was assuming they are already covered by the trait and I CAN just override them for individual config. I'll try the full setup
Dennis Koch
Dennis Koch13mo ago
Well, how should it know which columns and query you want if you don't specify anything? 🙈
btx
btx13mo ago
I did now the full implemenation, but still get the same error 😦 When I change "Component" to Lifewire\Component, I can not use it in the form builder.
Dennis Koch
Dennis Koch13mo ago
Wait you are using this inside a form? That doesn’t work. Also Filament form components aren’t Livewire components. Maybe try a table widget to show above or below the form
btx
btx13mo ago
I created some tabs on The Circle/View page class ViewCircle extends ViewRecord, where I want to have the Dates in a separate tab. How would you suggest so solve it? Should I create a Livewire component for ViewCircle instead ? I was just using the protected function getFormSchema(): array after generating the view page
Dennis Koch
Dennis Koch13mo ago
You can put tabs on that page and add the form to one and the table to the other but you cannot put a table inside a form. Might be possible with v3
btx
btx13mo ago
guess I got the point thank for assistance
Want results from more Discord servers?
Add your server
More Posts