I have a Contact Domain class that can be associated with multiple Organizations, which are also domain classes. I want to use a multiple selection box to allow the user to select the organizations that are associated with the current contact. The selection box is populated with the available organizations. How do I assign the selected items to the organizations list in my Contact class?
<g:select name="organizations.id" multiple="multiple" optionKey="id" from="${com.ur.Organization.list()}" value="${contact?.organizations}" />
The above is what I am currently trying, and while it does populate the selection with organizations it doesn't seem to put the selected items in my organizations field.
Thanks for any advice.
Edit: Incorporated comments from krsjunk and omarello.
Here's an abbreviated version of the domain classes.
class Contact{
static searchable = true
static mapping = {
sort "lastName"
}
String firstName
String lastName
.
.
.
static belongsTo = [organizations:Organization, projects:Project]
}
class Organization {
static searchable = true
static mapping = {
sort "name"
}
String name
static hasMany = [contacts:Contact]
}