I have a g:select in my view that displays a list of products:
<g:form name="addproductform" action="saveProductToInventory" method="post">
<g:select from="${products}" name="product" value="${it?.id}" />
<g:hiddenField name="inventory.id" value="${inventoryInstance.id}" />
<input class="save" type="submit" value="Save product" />
</g:form>
${products} is a list of all products. If I print the params variable that is passed to the controller, I get this:
[product:Test Product, inventory:[id:1], inventory.id:1, action:saveProductToInventory, controller:inventory]
The product key contains the name, and not the ID which I thought it would contain when I added value="${it?.id}" to the g:select tag.
How do I need to declare the g:select tag to render the product's name as it is right now, but pass the product's id as value?