Selecting multiple values from select tag - Grails

早过忘川 提交于 2019-12-01 00:16:50

Your MME is because the get() on Domain classes only handles one id at a time. For multiple ids from your <select/> use.

def validators = Validator.getAll(params.list('validator.id'))

The params.list() will always fetch 'validator.id' as a List even if there's only one, which will save you from having to test for single vs multiple results from your <select/>.

According to this docs: http://www.grails.org/doc/1.3.7/ref/Tags/select.html your select tag is wrong, it should be rather:

<g:select name="validator.id"
    multiple="multiple"
    optionKey="id"
    from="${com.project.Validator.list()}"
    value="${contact?.validators*.id}" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!