2 Usage - Reference Documentation
Authors: Rob Fletcher
Version: 1.5
2 Usage
The plugin provides a set of tags you can use to render the fields in a form.In the simplest case you can use f:all to render a field for every property of a bean (the domain object or command the form will bind to):<g:form…>
<f:all bean="person"/>
</g:form>
<g:form…> <f:field bean="person" property="name"/> <f:field bean="person" property="address"/> <f:field bean="person" property="dateOfBirth"/> </g:form>
<f:field bean="person" property="address"/>
<f:field property="password"> <g:password name="password"/> </f:field>
<f:widget bean="person" property="name"/>
<g:form…> <f:with bean="person"> <f:field property="name"/> <f:field property="address"/> <f:field property="dateOfBirth"/> </f:with> </g:form>
<f:display bean="person" property="name"/>
<f:display bean="person" property="dateOfBirth"> <g:formatDate format="dd MMM yyyy" date="${value}"/> </f:display>
<dt>${label}</dt> <dd>${value}</dd>
Breaking changes
Templates
The names of the templates were changed for more adequate ones:- _field to _wrapper
- _input to _widget
- _display to _displayWrapper
- _displayWidget was added
Config.groovy
grails.plugin.fields.wrapper = "field" grails.plugin.fields.displayWrapper = "display" grails.plugin.fields.widget = "input"
Widget attributes
To pass additional attributes to widgets, prefix them with 'widget-'.Example:<f:field property="birthDate" widget-format="dd/MM/yyyy"/>
Config.groovy
:
grails.plugin.fields.widgetPrefix = "input-"
Changes in tags
- The input tag was deprecated because the name was confusing. Use the new widget tag instead.
- The displayWidget tag was added. It outputs the widget for display purposes, without the wrapper (similar to the widget tag).