Grails multiple select binding

When first time I try to use html select tag with multiple selection, I spent about 1h to figure "how to" because user guide is, hmmm, as is. So, there is my little example:

Lets create domain objects:

 
Author {
    String firstName
    String lastName
    static hasMany = [books:Book]
}
 
 
Book {
    String title
    static belongsTo = [author:Author]
}
 

Author form will contain select with books like this:

 
<g:select optionKey="id" optionValue="title"  multiple="multiple" name="author.books" id ="author_books" from="${allBooks}" value="${authorInstance?.books*.id}"/>
 

Multiple select binding to Author.books is now available.

Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds. Valid XHTML and CSS.