Custom Switch not working for me is there something I am doing wrong

Custom Switch not working for me is there something I am doing wrong.
it looks like it’s having an issue targeting the right value. can someone help me get it to point to the right ID

What exactly is the logic of the condition you are trying to use?

It’s hard to tell what exactly you are doing but it looks like you bound your checked value from the recordset instead of inside the repeat. I am suggesting this because of the [0] in your bind checked value.

So instead of selecting your value from your server connect recordset, select it from the data values in your repeat region.

If the user was assigned a privilege it should have the custom switch to blue. but when I do it even if the user has all the privileges it only switches just the first one.
and it’s not allowing me to switch the other either

Sorry your explanation is not really clear.
Can you explain what needs to mach what exactly and when? Which values ce from where and what’s the exact condition?

i have a list of permission coming from the database and i want to be able to use the custom switch to select them and assign them to the user. when I use checkbox input it works but when I try the custom switch it not allowing me to click on the rest of the switches

This worked

but not with switch
image

Not entirely sure about this but they are repeated you may need a dmx-bind:id on the input and something like dmx-bind:for on the label think I had an issue like this once ill try find what I was working on.

Yes i saw an answer on the forum but it was not clear on how to solve that issue, soothing about dynamic id dmx-bind:id

<input class="form-check-input" type="checkbox" id="input1_1" dmx-bind:id="input1_1_{{$index}}" name="input1_1[]" dmx-bind:checked="query[0].user_id_member" dmx-bind:value="pages_roles_id">
<label class="form-check-label" for="server_role_admin" dmx-bind:for="input1_1_{{$index}}">{{pages_role_name}}</label>

This is one I did a while back essentially the original for and id is to stop any console errors, then the dmx-binds are used to generate the new dynamic id and for

As you can see on my input I have
dmx-bind:id="input1_1_{{$index}}"
Which essentially makes the id different in the repeat as $index is the repeats index and will go up in each loop other dynamic data can be used if needed

Then you want the label to match up so mine is
dmx-bind:for="input1_1_{{$index}}"

input1_1_ can be anything that’s just what mine was set to the important part is {{$index}}

thanks but anyway, i try that but still no working i appreciate you guys.

That’s a shame just to check did you also put the dmx-bind:for on the label other wise if I remember right it will still only affect the top one or none at all if you click the label although clicking the actual switch might work if you only tried the input

If that doesn’t work sure the team and community will be able to provide more help.

this is what it looks like :slight_smile:

name

Your for isn’t a dmx-bind try this

for="checkbox_privilages" dmx-bind:for="checkbox_privilages_{{$index}}"

on the label

1 Like

hey buddy, thank you so much it’s working now

1 Like