grails - <g :countrySelect> Tag: How to set values as country names instead of country codes

标签 grails

在我看来,不要使用普通的 <g:textField>表单中的字段,我想利用 Grails' <g:countrySelect>小部件。

我的问题

<g:countrySelect name="country" value="${myObjInstance?.country}"/>

...产生...

<select name="country" id="country">
   <option value="afg">Afghanistan</option>
   <option value="alb">Albania</option>
   ...
</select>

这意味着,提交表单时,它将将该值指定为国家/地区代码(例如“afg”),而不是国家/地区名称(“阿富汗”)。我更喜欢使用完整的国家/地区名称作为值。如果可能的话,我该如何实现这一目标?

最佳答案

我不相信标签库本身能够给你这种能力。您需要扩展它或使用您自己的国家/地区集合 +

关于grails - <g :countrySelect> Tag: How to set values as country names instead of country codes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11685324/

相关文章:

java - 在Grails中,是否有一种方法可以限制HTTP请求方法类型(allowedMethods映射除外)?

grails - 运行时出现Grails错误

grails - 将Java字符串数组发送到.gsp并显示所有元素

grails - doWithDynamicMethods访问服务

grails - 自动将新的Grails版本添加到Jenkins Grails

java - 在 grails 2.3.7 中上传文件时出错

macos - GGTS 3.6.4(OSX 64位)错误-系统属性http.nonProxyHosts已设置为本地

layout - 在布局上获取域变量

grails - 如何覆盖Grails 3 Controller 的重定向

grails - 有没有类似 Plone 的 CMS,但是是在 Grails 中?