livewire-select
livewire-select copied to clipboard
Wire:model not updating on change
I'm not sure how this works since there is no documentation, but when a value is selected there is no change to the model.
<livewire:user-select wire:model="selectedUser" wire:change="change" name="user_id" value="$selectedUser" placeholder="Choose A User" />
the parent component echos the value selectedUser, but it never changes. If you do this in a standard input form like livewire documents suggest. it works. Am I missing something?
From what I've seen the livewire select component currently just emits an event when it changes values, so as a workaround for the time being you could catch it with a listener like below. What I've done after looking at the code (particularly this part) is something like this:
<livewire:selects.advert-format-select
name="mediaFormatId"
:value="$mediaFormatId" />
protected $listeners = [
'mediaFormatIdUpdated' => 'setMediaFormatId',
];
public function setMediaFormatId($object)
{
$this->mediaFormatId = $object['value'];
}
hello @Neoglyph still not working for me
hello @Neoglyph still not working for me
Which part? Did you create the select class correctly, did you call the listener the correct way and in the correct component class, ... Without an example of your code I can't really help much, not knowing what the issue is.
Thanks for sharing this solution. I spend a few days to understand how can get the value, and only need to include a listener into my component and all this.