Hidden reactive input loses value when it change.
Hi, i'm using a hidden input in a component to set a value trow js to save it in bbdd when the form is saved.
The problem is when this value is changed and livewire render the view, the value="" attribute is deleted, but the value continues storaged in state.
5 Replies
All hidden inputs loses value attribute when 1 is reloaded.
This issue occurs since I update to v3
How are you defining hidden inputs
And should you be passing them as hidden? and not as mutatebeforesave?
Hidden::make($this->getStatusComponentName())
->default(array_keys($this->options)[0])
->reactive()
->extraAttributes([
'data-progressChildStatus' => $this->getName()
])
And i'm changing the value by JS. Getting the element and doing a element.value = "new value"
By doing that, as the component is reactive and changes its value, livewire makes a render. That's when you delete the value.
The first time the page is load, the value is created correctly with the value that i define in default()
But the problem is when i change it
@toeknee
I adding
'value' => $getState()
in the Hidden field component view. It works.
vendor/filament/forms/resources/views/components/hidden.blade.php
I was going to say, you are clearing them on the live and not setting them again, if you want to set defaults you can but you tend to do that in the form fill method/
Ok, thanks