(Quick Reference)



f:field renders the input using either f:input or the tag body accompanied by any surrounding markup, typically a container, a label tag and any validation messages.

By default the f:field tag will output:

<div class="fieldcontain">
    <label for="foo">Foo</label>
    <!-- the input as generated by f:input or the tag body -->

The intention is that f:field should typically be used without a tag body. For example:

<f:field bean="person" property="name"/>

In which case the tag will use f:input to generate an appropriate input. Alternatively in more specialized cases you can give f:field a tag body. For example:

<f:field bean="person" property="name">
    <g:textField name="${property}" value="${value}"/>

See Customizing Field Rendering for details of the parameters passed to the tag body.

The f:field tag handles embedded domain properties in a special way. See Embedded Properties for details.


beanyes for f:input if not inside f:with , optional for f:field The bean whose property is being rendered. This can be the object itself or the name of a page-scope variable.
propertyyesThe path to the property. This can include any level of nesting and numeric or string indexes. For example employees[0].address[home].street is a valid path.
value Overrides the actual value of the property.
default A default value for the property that will be used if the actual property value is falsy .
required Overrides the required status of the property. By default this is worked out based on the property's constraints.
invalid Overrides the validity of the property. By default this is worked out using the bean's errors property for domain and command objects.
label Overrides the field label passed to the template. This value may either be an i18n key or a literal string.
prefixStringA string (including the trailing period) that should be appended before the input name such as name="${prefix}propertyName". The label is also modified.

Any additional attributes are passed to the rendered template. Any additional attributes prefixed with input- are instead passed to the input template or rendered on the default input.