title: Set Option Key and Value on Grails select list?
body: <p>I am currently working on a Grails application and I am looking place a select list on the page and have its Key set to one value and the Value set to another. The code of all related elements is below:</p>
  
  <p><strong>Domain Object:</strong></p>
  
  <pre><code>class Cars {
    String carType
    String car
  }
  </code></pre>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>def create() {
    List cars = Cars.list()
    [dealerInstance: new Dealer(params), cars: cars]
    render(text:"This site in curently under Maintainence!")
  }
  </code></pre>
  
  <p><strong>View:</strong></p>
  
  <pre><code>&lt;g:select name="cars.id" from="${cars}" optionKey="${carType}" optionValue="${car}"/&gt;
  </code></pre>
  
  <p>Now when I run this code the list does get populated however data looks like below:</p>
  
  <pre><code>&lt;select id="cars.id" name="cars.id"&gt;
    &lt;option value="com.app.Cars : 1"&gt;com.app.Cars : 1&lt;/option&gt;
    &lt;option value="com.app.Cars : 2"&gt;com.app.Cars : 2&lt;/option&gt;
    &lt;option value="com.app.Cars : 3"&gt;com.app.Cars : 3&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>and then when I try this:</p>
  
  <p><strong>View:</strong></p>
  
  <pre><code>&lt;g:select name="cars.id" from="${cars.car}" optionKey="${carType}" optionValue="${car}"/&gt;
  </code></pre>
  
  <p>I get the following:</p>
  
  <pre><code>&lt;select id="cars.id" name="cars.id"&gt;
    &lt;option value="Audi"&gt;Audi&lt;/option&gt;
    &lt;option value="BMW"&gt;BMW&lt;/option&gt;
    &lt;option value="Scoda"&gt;Scoda&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>This is not what I want at all I want to be able to set a different Key Value pair on this select list so that I can use that data within my application, I would want the following to be generated:</p>
  
  <pre><code>&lt;select id="cars.id" name="cars.id"&gt;
    &lt;option value="Saloon"&gt;Audi&lt;/option&gt;
    &lt;option value="Hatch Back"&gt;BMW&lt;/option&gt;
    &lt;option value="Estate"&gt;Scoda&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Can someone please tell me how I achieve this within Grails???</p>