localeSelect
用途
创建一个选择下拉框,从列表中选择可用的locales
示例
// create a locale select
<g:localeSelect name="myLocale" value="${locale}" />
描述
属性
name
- 选择框的名称
value
(optional) - 设定的locale ,如果没有指定,默认为当前请求的locale
来源
Show Source
def localeSelect = {attrs ->
attrs['from'] = Locale.getAvailableLocales()
attrs['value'] = (attrs['value'] ? attrs['value'] : RCU.getLocale(request))
// set the key as a closure that formats the locale
attrs['optionKey'] = {"${it.language}_${it.country}"}
// set the option value as a closure that formats the locale for display
attrs['optionValue'] = {"${it.language}, ${it.country}, ${it.displayName}"} // use generic select
out << select(attrs)
}