Rendering of enumeration is already working fine. The problem is that, when the form get submitted, the "userRoles" fields does not get correctly binded to the User.userRoles property.
I added a few log lines for debugging, and I am seeing that the params.userRoles is an array of Enumeration names. However after I do new User(params), all properties gets assigned except the userRoles property.
Does anyone have a working example with Enumerations?
<g:select name="userRoles" from="${UserRole?.values()}"
value="${userInstance?.userRoles'}"
size="5" multiple="true" />
cinar wrote:
Hi,
Grails is not binding the Enumerations coming from the forms. Most likely I'm doing something wrong, any ideas?
Here are my domain objects:
class User {
static hasMany = [userRoles: UserRole]
}
enum UserRole {
ADMIN,
GUEST
}
Here is the select box on the form:
<g:select name="userRoles" from="${UserRole.values()}"
value="${fieldValue(bean: userInstance, field: 'userRoles')}"
valueMessagePrefix="userRole"
size="5" multiple="true" />
The select box gets rendered correctly, however when I submit the form, the userRoles property of User domain object does not get the values.
Here is my controller:
def userInstance = User(params)
Thanks in advance for your help.
-onur