Search code examples
grailsradio-buttongsp

grails Radio Button True or false checked property


I have radio group with two values. On editing a record, the radio should be set to checked or unchecked depending on the value from database.I use

    <input type="radio" name="value1" value="${someValue}" ${it.id == true ?'checked="checked"' : ''}>                         
     <input type="radio" name="value1" value="${someValue}" ${it.id == false ? 'checked="checked"' : ''}> 

Using such code, gives me syntax error. Please correct my syntax.


Solution

  • Can't you use:

    <g:radio name="value1" value="${someValue}" checked="${it.id}" />
    

    (assuming it.id is a boolean as you seem to say)