Search code examples
grailsfieldscaffolding

grails fields plugin widget String is escaped


I am using Grails 2.3.7 and Fields plugin version 1.3

With this in my _field.gsp under _fields folder

<%@ page defaultCodec="html" %>
    <div class="control-group ${invalid ? 'error' : ''}">
            <label class="control-label" for="${property}">${required? '*' : '' } ${label}
            </label>
        ${widget}
    </div>

The input tags are getting escaped and hence showing up as Strings instead of being rendered as html components.

I tried decoding them using widget.decodeHTML() but doesnt seem to make a difference.

Is there any other configuration I am missing to make this work?


Solution

  • In Grails 2.3.x you can use the raw() method in views to specify that your output is safe and should not be escaped. In your case:

    ${raw(widget)}
    

    This blog post by Mr. Haki should be helpful.