Details
Description
When using a <g:select /> with multiple selection enabled, there is no way at the moment to tell grails to "pre-select" multiple values. Changing the following (line 513 in 5.0):
if(keyValue==value) {
out << 'select="selected" '
}
to:
if(attrs.multiple) {
if((value instanceof ArrayList && value.contains(keyValue)) || (!(value instanceof ArrayList) && keyValue == value)) {
out << 'selected="selected" '
}
}
else {
if(keyValue==value) {
out << 'select="selected" '
}
}
allows doing something like this:
<g:select from="[1, 2, 3, 4]" value="[2, 4]" />
(I guess there might be a cleaner way to do that, though)
Grmbl, how clumsy can one get... I failed on copy-pasting...
Correct (and nicer), version:
changed to