title: Grails form data binding when another domain object is referenced in the form
body: <p>How do I get Grails data binding to correctly bind referenced objects (such as Country in the example below)?</p>
  
  <p>Given the following two Grails domain classes ..</p>
  
  <pre><code>class User {
    String username
    Country country
  }
  
  class Country {
    String name
  }
  </code></pre>
  
  <p>.. and the following HTML form ..</p>
  
  <p><code>&lt;g:form&gt;</code></p>
  
  <p><code>&lt;g:textField name="user.username" value="${user.username}" /&gt;</code></p>
  
  <p><code>&lt;g:select name="user.country" from="${Country.list()}" optionKey="id" /&gt;</code></p>
  
  <p><code>&lt;/g:form&gt;</code></p>
  
  <p>.. and the following code in the corresponding action ..</p>
  
  <pre><code>User user = new User(params["user"])
  </code></pre>
  
  <p>.. I would have hoped that user.username and user.country would get bind. However, it appears as if username.username gets bind, whereas user.country is not. What is the correct syntax to bind referenced objects (user.country in this example)?</p>