I am trying to create an update page and i've completed most of the page, with exception to the checkbox section. For some reason that i've yet to figure out, the checkboxes are duplicated. I am using laravel.
This is the code for that particular section of the form.
<div class="form-group">
<label>Focus Area</label>
<br>
@foreach(FocusArea::all() as $focusArea)
@if(isset($project))
<div class="checkbox material checkbox-success">
<label>
@foreach($project->getIdsOfFocusAreas() as $selectedFocusArea)
@if($selectedFocusArea == $focusArea->focus_area_id)
<input type="checkbox" name="focus-area[]" value="{{ $selectedFocusArea }}" checked>
@else
<input type="checkbox" name="focus-area[]" value="{{ $selectedFocusArea }}">
@endif
@endforeach
{{ $focusArea->name }}
</label>
</div>
<br>
@endif
@endforeach
</div>
Some extra information:
The number of elements in the array generated by FocusArea::all() is 5.
The number of elements in the array generated by getIdsOfFocusAreas() is 2.
I know that it is duplicating twice because of point number 2, im just not exactly sure why it is duplicating in the first place.