Selecting multiple values from select tag - Grails

前端 未结 2 1412
南笙
南笙 2021-01-06 21:18

Could you please anyone tell me how to get multiple values from

I have this in my create.gsp

相关标签:
2条回答
  • 2021-01-06 21:24

    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}" />
    
    0 讨论(0)
  • 2021-01-06 21:29

    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/>.

    0 讨论(0)
提交回复
热议问题