[V3] Difference in update hook when binding to array compared to V2 #6665
Replies: 14 comments 13 replies
-
I don't think it's a problem, because internally it's not setting the If I call public function updatedSelectedCheckboxes($value, $value2)
{
// after unchecked "three": $value = "__rm__", $value2 = 2 (index)
// after checked "three": $value = "three", $value2 = 2 (index)
dump($value, $value2);
} I don't know what the best approach is, maybe not using the |
Beta Was this translation helpful? Give feedback.
-
@AntonioDiPassio-AppSys thanks for reporting! Can you provide screenshots of both the dumps? Thanks! |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I'm having the same problem with a multi select box. When items are removed, they get replaced by "rm", which makes it to the backend as well. I have to run this in the render method:
Had no issues in Live Wire 2. Any ideas? |
Beta Was this translation helpful? Give feedback.
-
Same problem, I've to move all updated logic when value is an array to the rendering method. |
Beta Was this translation helpful? Give feedback.
-
Same issue with multi-select. Unselecting will cause the removed item to be replaced with " Looking at the network from devtool, the following is observed under "updates" object:
Forgot to mention, and because of this |
Beta Was this translation helpful? Give feedback.
-
Any ideas on this topic? Thank you! :) |
Beta Was this translation helpful? Give feedback.
-
This is a breaking change for our application, rendering it completely unusable and blocking any attempts at working around the issue and upgrading to v3. Was this change intentional or is this a bug? If this was intentional and is the new way forward, there is no way we can continue using Livewire because our application relies on many inputs with huge arrays. If this is a bug, can anyone with knowledge on the matter please have a look at it? I'd be glad to contribute and help but this is way beyond my knowledge of the Livewire internals and it's surely impacting a large number of users, many of whom may not even be aware of the issue as it's not documented in the upgrade guide. |
Beta Was this translation helpful? Give feedback.
-
Any news on this topic? Thank you! |
Beta Was this translation helpful? Give feedback.
-
Hello, there is a hack. You can pass an object rather than an array in JavaScript and everything will work as in Liwevire2.
After:
|
Beta Was this translation helpful? Give feedback.
-
Any news on this topic? Thank you! |
Beta Was this translation helpful? Give feedback.
-
This bug is still there in V3.4.9. EDIT: Sorry to ping you @joshhanley but is that a confirmed bug or we do something bad ? /**
* Function to update the model and return it after.
*
* @return Maintenance
*/
public function update(): Maintenance
{
// Hack to counter a bug in Livewire
// https://github.com/livewire/livewire/discussions/6665
$this->operators = array_filter($this->operators, fn ($value) => $value !== '__rm__');
$this->companies = array_filter($this->companies, fn ($value) => $value !== '__rm__');
$this->incidents = array_filter($this->incidents, fn ($value) => $value !== '__rm__');
//... And i'm pretty sure that when I developped my website like 4/5 months ago, this bug wasn't there. |
Beta Was this translation helpful? Give feedback.
-
After much digging, I have finally found out the cause on my end for appending My component is using a custom trait that will trim strings upon any form submission and the trait is not taking into account of If you are facing this |
Beta Was this translation helpful? Give feedback.
-
What equivalent for this?
but on v3 this not working
|
Beta Was this translation helpful? Give feedback.
-
Livewire version
v3.0.1
Which PHP version are you using?
PHP 8.1
Repository URL
No response
Steps To Reproduce
Setup both a livewire 2 and livewire 3 installation:
Livewire 2
Livewire 3
Notice the difference in the 2 dumps. In V2 the updated hook is called once with an array of the values, in V3 the updated hook is called for every value in the array, with a weird rm value in the mix.
Additional information
No response
Please confirm (incomplete submissions will not be addressed)
Beta Was this translation helpful? Give feedback.
All reactions