Paolo Bolis
Paolo Bolis

Reputation: 43

render Grails tag in controller

I've to render a select when calling a controller function.

class FormController {
    def document() {
        render """<g:select name="tipo" from="${['','one','two']}" />"""
    }
}

it doesn't work.. In the html appear nothing when I replace a div with this function.

Upvotes: 4

Views: 1614

Answers (2)

IgniteCoders
IgniteCoders

Reputation: 4980

//Build your output string as the next:
def output = g.select(name:"tipo" from:['','one','two'])
//And add any other string or tag if you need
output = "Tipo: " + output
render (text: output)

Upvotes: 0

Ian Roberts
Ian Roberts

Reputation: 122364

Use the tag as method call syntax instead:

render g.select(name:"tipo" from:['','one','two'])

Upvotes: 6

Related Questions