Choices
Choices copied to clipboard
Laravel livewire wire:model directive gets {value: 'value'} instead of 'value' on change
Laravel livewire wire:model directive gets {value: 'value'} instead of 'value' on change
Steps to reproduce the behavior: add wire:model to select, init choices and select something.
after selecting something it should return clear value except of json object unless it's multiple
Desktop (please complete the following information):
- OS: Windows 10 20H2
- Browser Chrome
- Version 89.0.4389.114
Any suggestions?
you can use this
Nope, I'm using a module with internal livewire call, so for now i catching updating hook on livewire side and processing input from choices selects.
That's what I do too, but it seems there could be a better solution.
if( is_array($this->customer_id) ) { // choices.js value is an array $this->customer_id = $this->customer_id['value']; }
That's what I do too, but it seems there could be a better solution.
if( is_array($this->customer_id) ) { // choices.js value is an array $this->customer_id = $this->customer_id['value']; }
Made exactly same thing but this is a crutch
Actually that works:
... wire:change="$set('customer_id', $event.target.value)"
Actually that works:
... wire:change="$set('customer_id', $event.target.value)"
Yep, but, I have module that return me a function in x-data, there I call this.$wire.set() and so on
No matter where to process input, problem is - why I need nested key "value" if there no other keys in input.
Having the same issue. Echoing a model's value in blade gets actual value, but if inspecting a model ($foo
) in the Livewire's hook updatedFoo($value)
gets an object of {value: $value}
.
I had similar problem and found a working solution there: https://forum.laravel-livewire.com/t/select-and-select-multi/1120
However, choices.js was losing style after update DOM, so I added to div with x-data:
wire:key="rand()" wire:ignore
anyone got a working solution for this?