Modelable to bind a parent property to a child property
Hello,
I have a Livewire (version 3) application with a parent Livewire component and a child Livewire component. Is it possible to use the Modelable attribute in the child component to bind an uploaded file to the parent component ?
When I do so, the uploaded file passed to the parent component looks like this.
@vincent15000 I’ve found Alpine’s v-model directive doesn’t really play nicely with file inputs, and you have to instead just set a property on change:
I don't really understand how you suggestion is a solution to my problem. Can you explain me ?
For the moment I have this solution and it works.
public function updatedImage()
{
$this->displayedImage = $this->image->temporaryUrl();
$this->dispatch('image-updated', $this->image);
}
To retrieve the file object instead of a simple string like livewire-file:g6UgtWw3tPQacJ2LxS7hpzE9ta9pTD-metaaG9tZS5wbmc=-.png, I just have to unserialize the string.