Search code examples
phparrayslaravellaravel-livewireunset

Table row is not removed using Livewire


I have a dynamic row created, and I want to remove the row but only the data from that row is removed and the input fields are not updated. I am using Livewire in this for creating the row and removing the row. The UI of the input fields are not removed.

I have tried this but this only removed the data from the row.

This is the button code:

public function removeRow($index){
   array_splice($this->createChallanRequest['order_details'], $index, 1);
}
 

Solution

  • After unset the array we need to update the array again with the new data and update the index number as well.

    unset($this->request['details'][$index]); 
    $this->request['detail'] = array_values($this->request['detail'])