Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails RadioGroup, how to bind labels to radio name

I'm struggling arround with the g:radioGroup tag -- I want to create some radios and some labels correspondig to the radios:

<g:radioGroup name="stateOfHealth" value="${review.stateOfHealth}" id="stammp"
        labels="['1','2','3','4','5']"
        values="['bad','suboptimal','well','veryWell','excellent']">
    <span class="radioSpan"> ${it.radio}</span>
    <label for="${ ???? }">${it.label}</label>
</g:radioGroup>

What do I need to do to insert in the label's "for" attribute to match the right radio?

like image 598
john Smith Avatar asked Apr 20 '13 15:04

john Smith


1 Answers

You don't need to set the for attribute, just wrap the radio with the label, like this:

<g:radioGroup name="stateOfHealth" value="${review.stateOfHealth}" id="stammp"
        labels="['1','2','3','4','5']"
        values="['bad','suboptimal','well','veryWell','excellent']">

    <label>
            <span class="radioSpan">${it.radio}</span>
            ${it.label}
    </label>

</g:radioGroup>
like image 64
Elias Dorneles Avatar answered Sep 18 '22 17:09

Elias Dorneles