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

cbhai's avatar
Level 2

wire:model with array of arrays

I have livewire component which displays 4 tables . These tables sync with array of arrays.

CODE INSIDE LIVEWIRE CONTROLLER :

public $estimateWorkitems = [];

ddd($estimateWorkitems) outputs :


array:4 [▼
  0 => array:2 [▼
    0 => array:6 [▼
      "name" => "Kitchen wall tiling"
      "description" => "Wall tiling using vitrified tiles"
      "unit" => "rft"
      "rate" => "90.00"
      "total" => 0
      "is_saved" => true
    ]
    1 => array:6 [▼
      "name" => "Kitchen Flooring"
      "description" => "Flooring with vitrified tiles"
      "unit" => "rft"
      "rate" => "100.00"
      "total" => 0
      "is_saved" => true
    ]
  ]
  1 => array:2 [▶]
  2 => array:1 [▶]
  3 => array:1 [▶]
]

INSIDE LIVEWIRE BLADE CODE :

I am trying to run for loop to attach each array to table.

[For Table 1 ]


@forelse ($estimateWorkitems[0] as $index => $estimateWorkitem )
                            <tr><td>
                                    <input type="text" name="estimateWorkitems[0][{{ $index }}]['name']"
                                        wire:model="estimateWorkitems[0].{{ $index }}.name" />

This shows blank textbox. How do I make this work?

Thank you

0 likes
0 replies

Please or to participate in this conversation.