Selecting radio option in a dynamic repeat

I have a dynamic repeat of a radio option group. But when I click on a radio option Label is selects the first option.
I have to physically click the Radio element to select the option, rather than the label.
I understand the and radio ID have to be unique in the repeat but I thought I achieved this.

Can someone kindly assist me?

<div class="form-check" dmx-repeat:repeatoptions="sc_questions_options.data.query_options">
                                <input class="form-check-input" type="radio" id="ind_responseInput_{{ind_option_id.value}}_{{$index}}" name="ind_responseInput" is="dmx-radio" dmx-bind:value="ind_option_id" required="" data-msg-required="Select the correct option" dmx-bind:disabled="sc_questions_options.data.query_last_response.ind_resp_option_id">
                                <label class="form-check-label" for="ind_responseInput_{{ind_option_id.value}}_{{$index}}">
                                    <h5>{{ind_option_content}}</h5>
                                </label>
                            </div>

use the dynamic dmx-bind:for="" for the label

1 Like

Great thanks @famousmag! I also had to do it for the input id.
So in the end the correct code is:

<div class="form-check" dmx-repeat:repeatoptions="sc_questions_options.data.query_options">
                                <input class="form-check-input" type="radio" dmx-bind:id="ind_responseInput_{{ind_option_id.value}}_{{$index}}" name="ind_responseInput" is="dmx-radio" dmx-bind:value="ind_option_id" required="" data-msg-required="Select the correct option" dmx-bind:disabled="sc_questions_options.data.query_last_response.ind_resp_option_id">
                                <label class="form-check-label" dmx-bind:for="ind_responseInput_{{ind_option_id.value}}_{{$index}}">
                                    <h5>{{ind_option_content}}</h5>
                                </label>
                            </div>

yes, off course! All the inputs inside a repeat should have a dynamic id (unique) otherwise an error is created.
I didn't pay attention to the input id because I focused on label as you mentioned at was your problem :slightly_smiling_face:

1 Like