show enum as radio button in gsp

grails

Solution

This should work:

<g:radioGroup name="type"
                  values="${test.Product$Type?.values()}"
                  labels="${test.Product$Type.values()*.name()}"
                  value="${productInstance?.type?.name()}">
  ${it.radio} <g:message code="${it.label}" />&nbsp;
</g:radioGroup>

That should replace the current `g:select` in `grails-app/views/product/_form.gsp`

Problem

In my domain class, i have one enum:- ``` class Product{ Type type enum Type{ MEDICINE, NON_MEDICINE } } ``` By generating default view, this shows as a dropdown in create.gsp page. My requirement is to show it as a radio group in create page from where i can select any one of the two values by clicking on radio button. can anyone provide some help. thnks

Original source