Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Pawooo's avatar

Stuck trying to populate multiselect field (TALL + Filament V3 Custom single Edit/View Page)

Laravel/Filament newbie. Any help would be much appreciated :)

I have data stored in M:M table

primary_id company_id prefecture_id timestamps
183	1	3	2023-11-09 08:33:37	2023-11-09 08:33:37
184	1	5	2023-11-09 08:33:37	2023-11-09 08:33:37
185	1	7	2023-11-09 08:33:37	2023-11-09 08:33:37

I'm trying to mount() it in Livewire V3 (Filament) CompanyRegions.php

    public function mount(): void {
        $tenant = Filament::getTenant();
        $companyID = $tenant->id;

        $companyPrefectures = auth()->user()->companies->find($companyID)->prefectures;

        $existing_prefectures = [];
        foreach($companyPrefectures as $prefecture) {
            Log::info($prefecture->prefecture_ja);

            array_push($existing_prefectures, $prefecture->id);
        }

         $this->form->fill($existing_prefectures);

But I end up passing fill($existing_prefectures) this:

    +data: array:4 [▼
      0 => 3
      1 => 4
      2 => 6
      "prefecture_id" => []
    ]
  }

doing fill($companyPrefectures->attributesToArray()) also does not work (method does not exist error)

I feel like I'm almost there but don't understand something important. Or maybe https://livewire.laravel.com/docs/lifecycle-hooks#mount only accepts non-complex data, I don't know. fill($data) works just fine for me for Models that have simple input fields.

0 likes
1 reply

Please or to participate in this conversation.