I use unisharp laravel filemanager.
How I click the button and change a file - file name show in the input, but model:image_url don’t update. When editing other models, the file name on input is cleared.
How to update the model with image_url when selecting a file?
I have resourse.components.download-button:
<div>
<span class="absolute inset-y-0 right-0 flex items-center pl-2">
<button id="lfm" class="p-1 focus:outline-none focus:shadow-outline"
x-data ="{field: '{{$field}}'}"
x-ref="button"
x-init="
document.getElementById('lfm').addEventListener('click', (event) => {
event.preventDefault();
window.open('/admin/laravel-filemanager', 'fm', 'width=1050,height=600');
var target_input = document.getElementById('{{$field}}');
window.SetUrl = function (items) {
var file_path = items.map(function (item) {
return item.url;
});
target_input.value = file_path;
target_input.focus();
};
});
"
>
<svg class="fill-current w-4 h-4 mr-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M13 8V2H7v6H2l8 8 8-8h-5zM0 18h20v2H0v-2z"/></svg>
</button>
</span>
</div>
and blade:
<div class="mb-3">
<label class="block font-medium text-sm text-gray-700" for="image_url">Image</label>
<div wire:ignore class="relative text-gray-600 focus-within:text-gray-400">
<x-download-button
field="image_url"
/>
<input wire:model="image_url" class="items-center form-input rounded-md shadow-sm mt-1 block w-full" id="image_url" type="text" autocomplete="image_url">
</div>
</div>
livewire controller:
public $image_url,
laravel 8 livewire 2.0