Search code examples
selectgrailsgsp

How can I customize grails select tag


I want to customize grails select tag

I tried this code

<g:select name="totalHour" from="${1..20}" value="${holdingVacationInstance}"/>

this code select options look like this

1, 2, 3, ... , 20

then, how can i make like this

0.5, 1.0, 1.5, ... , 20.0


Solution

  • You can use like this

    <g:select name="totalHour" from="${(0.5..20).step(1)}" value="${holdingVacationInstance}"/>
    

    Then it will give output like [0.5, 1.5, 2.5, 3.5, ...] as per my concern you can't use non integer step. See here http://grails.asia/groovy-range-examples