select

Purpose

Helper tag for creating HTML selects.

Examples

// create a select from a range
<g:select name="user.age" from="${18..65}" value="${age}"
          noSelection="['':'-Choose your age-']"/>

// create select from a list of companies // note the 'optionKey' is set to the id of each company element <g:select name="user.company.id" from="${Company.list()}" value="${user?.company.id}" optionKey="id" />

// create select with internationalized labels (this is useful for small static lists and the inList constraint) // expected properties in messages.properties: // book.category.M=Mystery // book.category.T=Thriller // book.category.F=Fantasy <g:select name="book.category" from="${['M', 'T', 'F']}" valueMessagePrefix="book.category" />

Example as a method call in GSP only:

${select(from:aList,value:aValue)}

Description

Attributes

Source

Show Source