Show/Hide fields based on selection
Hello, I am trying to migrate my form wizard from v2 to v3, but I am having some issues with a dependent select field. On v2, I was using reactive on the first select field, and on my secondary select field, I was using
->hidden(fn (Get $get) => $get('provider')=== null )
to show/hide it if my provider select field had an option selected or not.
On v3, I am setting my provider field to ->live()
, and on my secondary one, I have: ->hidden(fn (Get $get): bool => $get('provider') === null)
but that does not seem to work. Also, when I make a selection on the provider one, I get a console error which I am not sure if it could be a bug or not. The error is attached.
The other additional piece of potential issue is that whenever I change the option on my provider select field, I clear the secondary one, and similarly, if I change the option on the secondary one, I clear a third one (the code for 3rd one not shown here).
Here is the link to the gist for the code I have on v3.
https://gist.github.com/rgut13rrez/42c660530ccb6fa6b4ae3e15483d5217
If it looks like a bug, and someone can point that out, I can follow up with a proper issue creating on github. ThanksSolution:Jump to solution
Ok, I can confirm that setting 'inject_morph_markers' => false, fixes the issue.
18 Replies
@Dan Harrin sorry for tagging you but might this be an issue with Livewire's new "auto-wire-key" thing?
yup thats the issue here
you can check that by disabling the feature in the lw config file
Oh he made it opt-in? Just for now?
its not opt-in
it can be disabled
so opt-out
Right. But at least there is a config option. Hope that will stay
yeah i bet
its too problematic of a feature to not have a toggle
just to confirm, you are talking about adding
'auto-wire-key' => false,
to the livewire config file?i think so
I added that, but it did not solve the issue. I also tried to find references to that or similar in the Livewire source code and had no luck.
clear your view cache after disabling it
I did, I ran optimize:clear before and just now I did view:clear and no luck
I also tried with underscores like
'auto_wire_key' => false,
just in case the config setting name was different but nothingyeah i think its a different bug then
Yeah, I think it is something else. I think I have narrowed it down to an issue when using the wizard layout. When I set up everything outside the wizard, all the hidden fields seem to work. I am going to set up a new component with dummy data so I can link to that to see if that helps finding the bug.
I dont expect any quick replies, I know you guys are busy….since my v2 version is working fine, just trying to help find weird bugs.
@rg.block the config option is called
inject_morph_markers
not sure where you found auto_wire_key
Oh ok, I wasn’t sure what was called, so I mentioned auto_wire_key and I thought that was it. Let me try that one.
Solution
Ok, I can confirm that setting 'inject_morph_markers' => false, fixes the issue.
I can also confirm that having it set to true works fine as long as I am not inside the wizard.
okay cool
at least we've narrowed that down