title: a list of checkboxes
body: <p>I have two domain classes</p>
  
  <pre><code>class Contract {
      String number
      static hasMany = [statements:Statement]
  }
  
  class Statement {
      String code
      static hasMany = [contracts:Contract]
  }
  </code></pre>
  
  <p>I would like to show all statements available in my gsp with a checkbox next to each, allowing the user to choose which statements are applicable to the contract. So something like:</p>
  
  <pre><code>[ ] Statement Code 1
  [ ] Statement Code 2
  [ ] Statement Code 3
  </code></pre>
  
  <p>I started off with this:</p>
  
  <pre><code>&lt;g:each in="${Statement.list()}" var="statement" status="i"&gt;
      &lt;g:checkBox name="statements[${i}].id" value="${statement.id}" checked="${contractInstance.statements.contains(statement.id)}" /&gt;
      &lt;label for="statements[${i}]"&gt;${statement.code}&lt;/label&gt;
  &lt;/g:each&gt;
  </code></pre>
  
  <p>But i just cannot get a list of checked statements to the controller (there are <code>null</code> elements in the list, there are repeated statements...).</p>
  
  <p>Any idea how to achieve this?</p>