What seems to be the problem:
I am trying to loop through an array and keep getting: Undefined offset: 1
It does not make any sense to me
<?php
namespace App\Http\Livewire\Frontend;
use Livewire\Component;
class TestForm extends Component
{
public $questionsList;
public function render()
{
$this->questionsList = [];
$this->questionsList[0] = 1;
$this->questionsList[1] = 2;
$this->questionsList[2] = 3;
return view('livewire.frontend.test-feedback-form');
}
}
<div>
@if (count($questionsList) > 0)
{{count($questionsList)}}
@foreach ($questionsList as $key => $value)
test
@foreach
@endif
</div>
Steps to Reproduce:
As the code is I get the error. If I comment out the foreach loop, the script runs fine and I can see my count array is 3 elements
Are you using the latest version of Livewire:
yes