I seem to be having a weird bug, and tbh I'm not sure where to start to get help. So the issue goes as follows:
I have an update blade file with following code:
<div class="form-group">
<label for="images" class="control-label" style="width: 100%;">Gallery</label>
@if ($event->images)
<div class="form-gallery">
@foreach ($event->images as $image)
<div class="form-gallery-item" style="background-image: url()">
<form action="" method="POST">
@csrf
@method('DELETE')
<button type="submit" class="form-gallery-remove"><i class="fal fa-trash-alt"></i></button>
</form>
</div>
@endforeach
</div>
@endif
<input type="file" class="form-control" id="images" name="images[]" multiple>
</div>
<hr>
<div class="form-group">
<label for="files" class="control-label" style="width: 100%;">Files</label>
@if ($event->files)
<ul class="form-files">
@foreach ($event->files as $file)
<li class="form-files-item">
<a href=""></a>
<form action="" method="POST" class="form-inline">
@csrf
@method('DELETE')
<button type="submit" class="form-file-remove"><i class="fal fa-trash-alt"></i></button>
</form>
</li>
@endforeach
</ul>
@endif
<input type="file" class="form-control" id="files" name="files[]" multiple>
</div>
Now when the images or files are being populated, each of them will have a delete button. For some reason the first item that comes (whether images is empty or not), will have it's form tag stripped.
This makes it impossible to have these delete buttons in the update parent form, cause the update form has it's method set to "DELETE" :(
If needed, Laravel version: v5.6.38
via Chebli Mohamed

Aucun commentaire:
Enregistrer un commentaire