Grails newbie – I’m trying to create URIs for the value attributes in my select markup (iterating over each object of a domain class). I tried using the createLink tag in my tag like so:
<g:select name="project.id" from="${Project.list(sort:'start', order:'desc')}" optionValue="${createLink(controller:'project',action:'show')}/${it.id}" noSelection="['null': 'select project']/>
Obviously I get a GSP exception, which explains that “/[mycontroller]/[myaction]/null” is not a property of the object.
Is there any other way of constructing these URI’s inside a <g:select> (e.g. <option value="/my/uri/"> without resorting to a loop and constructing the values “manually”?
It can be easily done by adding an extra method to Project domain:
and using it as: