How to find out currently checked Checklist boxes?
EDIT FROM THE FUTURE: In retrospect this is related to the inconsistency of results when using $get in different parts of the code - even withing the same field for example you will get a different result for
dd($get('cars')
when using in ->action() and a different one when using in ->visible(). My guess it's because of different life times they are employed, but this is super frustrating.
I don't know how to get the current value of my checkbox list.
When I do:
I will get a list of keys and values.
But I don't know which checkbox is toggled on.
how to see the real what-I-actually clicked list of items?19 Replies
If it’s in the array it’s checked.
Well, this is strange, I am getting:
when trying
dd($get['cars'])
The same dd($get('cars'))
doesn't work the same in visible() and in action(). In action it is completely ignored for some reason and show every checkbox available, not only the checked ones:
This inconsistent behavior is super frustrating and not what I would expect. Probably, as I said earlier, something to do with when those methods are being executed - so, perhaps action() is triggered before the checkboxes are even being filled so it shows me everything. And perhaps visible() fires later in the lifecycle when checkboxes are checked correctly based on what is saved in the DB ?
It would be cool to have some "await" like possibility so I could use $get('cars') even in action(). Because currently I can't.
Or if I can, let me know how. There is nothing on Google how to do that.I think the
action
is fired when you click submit then you can get the cars
using array $data
@WirkhofI am getting undefined array key for some reason, but will check my code one more time.
just dd the $data and you can get the checked values
I am getting an empty array
[]
for dd($data)then there is no currently check cars
No,
I have already prechecked stuff that is saved in db and repopulaed
and also I checked manually a few things.
I can't bring $form in action for some reason as well
I am using Checkbox List
I can't do even $form in action() as well https://discord.com/channels/883083792112300104/1218076957976170506
I absolutely don't get it why I can't get $data nad $form in action()
this is how I usually use the array data
maybe there is a misconfiguration idk but
array $data
is works perfectly fine for me
I can get all data from the form itself before saving it the databaseWell, you have it up top
I have my action on a button.
doest matter
array $data
will get all data from your form
can you share your full code?Maybe it's Tabs.
I will put it outside of tabs
and check there
if you don't share your code how can any other member here solve your problem and help you
What are you saying?
I am sharing code.
I am not available 24/7
every second
bruhh
wait
thanks for now
you just share this
dd($get['cars'])
how can anyone to expect to help you if you don't show your full code and analysze what is wrongHere is the code:
I should get something, but $data is an empty array after dd, so
[]
.why dont you use checkbox list form component ?