?? - select
?? Description
Helper tag for creating HTML selects.
HTML????????????????
????? Parameters
- from (??) - ????????????The list or range to select from
- value (??) - ??????????????????????????The current selected value that evaluates equals() to true for one of the elements in the from list.
- optionKey (??) - By default the value attribute of each "option" element will be the result of a "toString()" call on each element in the "from" attribute list. Setting this allows the value of the attribute to be a bean property of each element in the list
- optionValue (??) - By default the value "option" element will be the result of a "toString()" call on each element in the "from" attribute list. Setting this allows the value to be a bean property of each element in the list.
? Examples
// ?????????????create a select from a range
<g:select name="user.age" from="${18..65}" value="${age}" />// company????????????create select from a list of companies
// ?????company??????id?'optionKey'??????????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" />Example as a method call in GSP only:
GSP??????????????
${select(from:aList,value:aValue)}