© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•14mo ago•
5 replies
Pierrot

Table must not be accessed before initialization

Hello,

I'm encountering an issue with the dynamic visible function in my code. Whenever I select a value on input_1, I receive the following error:

Typed property App\Livewire\TagsManagerComponent::$table must not be accessed before initialization.

Here is an example of code to reproduce the problem:

TagsManagerComponent.php :

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

  public function mount(): void
  {
    $this->form->fill();
  }

  public function makeForm(): Form
  {
    return Form::make($this)->schema([
      TextInput::make('name')->required()->maxLength(255),
      ColorPicker::make('color')->required(),
      Select::make('input_1')
        ->options([
          'draft' => 'Draft',
          'reviewing' => 'Reviewing',
          'published' => 'Published',
        ])
        ->live()
        ->required(),
      TextInput::make('input_2')
        ->label('2')
        ->maxLength(255)
        ->visible(function (Get $get) {
          $input = $get('input_1');
          return $input !== null && $input !== 'draft' && $input !== 'reviewing';
        }),
    ]);
  }

  public function table(Table $table): Table
  {
    return $table
      ->query(Tag::query())
      ->columns([
        TextColumn::make('name')->searchable()->sortable(),
        ColorColumn::make('color')->searchable()->sortable(),
        TextColumn::make('input_1')->searchable()->sortable(),
        TextColumn::make('input_2')->searchable()->sortable(),
      ])
      ->headerActions([
        Action::make('create')->label('Add Tag')->form($this->makeForm()->getComponents()),
      ])
      ->paginated([10, 25, 50, 100, 'all']);
  }

  public function render()
  {
    return view('livewire.tags-manager-component');
  }
}
class TagsManagerComponent extends Component implements HasForms, HasTable
{
  use InteractsWithForms;
  use InteractsWithTable;

  public function mount(): void
  {
    $this->form->fill();
  }

  public function makeForm(): Form
  {
    return Form::make($this)->schema([
      TextInput::make('name')->required()->maxLength(255),
      ColorPicker::make('color')->required(),
      Select::make('input_1')
        ->options([
          'draft' => 'Draft',
          'reviewing' => 'Reviewing',
          'published' => 'Published',
        ])
        ->live()
        ->required(),
      TextInput::make('input_2')
        ->label('2')
        ->maxLength(255)
        ->visible(function (Get $get) {
          $input = $get('input_1');
          return $input !== null && $input !== 'draft' && $input !== 'reviewing';
        }),
    ]);
  }

  public function table(Table $table): Table
  {
    return $table
      ->query(Tag::query())
      ->columns([
        TextColumn::make('name')->searchable()->sortable(),
        ColorColumn::make('color')->searchable()->sortable(),
        TextColumn::make('input_1')->searchable()->sortable(),
        TextColumn::make('input_2')->searchable()->sortable(),
      ])
      ->headerActions([
        Action::make('create')->label('Add Tag')->form($this->makeForm()->getComponents()),
      ])
      ->paginated([10, 25, 50, 100, 'all']);
  }

  public function render()
  {
    return view('livewire.tags-manager-component');
  }
}


View :

{{ $this->table }}
{{ $this->table }}
image.png
Solution
likely has to do with
$this->makeForm()->getComponents()
$this->makeForm()->getComponents()
which you call when you make your action

I'd refactor your
makeForm()
makeForm()
method to just return an array of components
private static function getFormComponents(?params): array
{
  return [
    TextInput::make(),
    ...
  ];
}
private static function getFormComponents(?params): array
{
  return [
    TextInput::make(),
    ...
  ];
}
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Must not be accessed before initialization
FilamentFFilament / ❓┊help
2y ago
$view must not be accessed before initialization
FilamentFFilament / ❓┊help
7mo ago
$container must not be accessed before initialization
FilamentFFilament / ❓┊help
3y ago
$dataChecksum must not be accessed before initialization
FilamentFFilament / ❓┊help
3y ago