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. Thanks
Gist
order.php
GitHub Gist: instantly share code, notes, and snippets.
Solution:
Ok, I can confirm that setting 'inject_morph_markers' => false, fixes the issue.
Jump to solution
18 Replies
Dennis Koch
Dennis Koch12mo ago
@Dan Harrin sorry for tagging you but might this be an issue with Livewire's new "auto-wire-key" thing?
Dan Harrin
Dan Harrin12mo ago
yup thats the issue here you can check that by disabling the feature in the lw config file
Dennis Koch
Dennis Koch12mo ago
Oh he made it opt-in? Just for now?
Dan Harrin
Dan Harrin12mo ago
its not opt-in it can be disabled so opt-out
Dennis Koch
Dennis Koch12mo ago
Right. But at least there is a config option. Hope that will stay
Dan Harrin
Dan Harrin12mo ago
yeah i bet its too problematic of a feature to not have a toggle
rg.block
rg.block12mo ago
just to confirm, you are talking about adding 'auto-wire-key' => false, to the livewire config file?
Dan Harrin
Dan Harrin12mo ago
i think so
rg.block
rg.block12mo ago
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.
Dan Harrin
Dan Harrin12mo ago
clear your view cache after disabling it
rg.block
rg.block12mo ago
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 nothing
Dan Harrin
Dan Harrin12mo ago
yeah i think its a different bug then
rg.block
rg.block12mo ago
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.
Dan Harrin
Dan Harrin12mo ago
@rg.block the config option is called inject_morph_markers not sure where you found auto_wire_key
rg.block
rg.block12mo ago
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
rg.block
rg.block12mo ago
Ok, I can confirm that setting 'inject_morph_markers' => false, fixes the issue.
rg.block
rg.block12mo ago
I can also confirm that having it set to true works fine as long as I am not inside the wizard.
Dan Harrin
Dan Harrin12mo ago
okay cool at least we've narrowed that down