Why use <g:textField /> in Grails?

knorv picture knorv · Jun 28, 2009 · Viewed 12.5k times · Source

What is the reason to use g:textField in Grails if you're already familiar with standard HTML form tags?

If I understand correctly the following two markup alternatives are equivalent:

<input type="text" name="name" value="${params.name}" id="name" />
<g:textField name="name" value="${params.name}" />

Are there any circumstances under which using g:textField would add value? Am I missing something?

Answer

John Wagenleitner picture John Wagenleitner · Jun 29, 2009

The textField tag is provided as a convenience (slightly shorter than writing the HTML input) and is there to provide a full set of form tags. Personally I prefer to write as much plain HTML as possible in my Grails views and only tend to use the tags that really offer a benefit such as the form tag. I have not found an instance where using textField would have added any value outside of requiring a few less characters to type.