<nerderg:inputfield label='First name' field='firstname' bean='${myCommand}'/>
The above tag will produce something like this (depending on CSS):
for example:
where the formCommand bean looks like this:
will produce:
and look something like this:
See source
Tag specific attributes
- type - set the input type e.g. password, text. The default type is text unless the field name is "passwd" or "password" in which case it defaults to password. You can set the type to anything you like but I only recommend using this input as textual input.
- maxlength - override the automatic maxSize -> maxlength attribute from the constraints in the bean.
Notes
- The inputfield tag produces a text input field displaying the value of the bean.field. If the bean has a constraints property with the maxSize set it will automatically include maxlength in the input specification.
for example:
<nerderg:inputfield label='First Name' bean='${formCommand}' field='firstName'/>
where the formCommand bean looks like this:
class FormCommand {
String firstName
static constraints = {
firstName(nullable: false, blank: false, maxSize: 10)
}
}
String firstName
static constraints = {
firstName(nullable: false, blank: false, maxSize: 10)
}
}
will produce:
<div class='prop'>
<span class='name'><label for='value'>First Name:</label></span>
<span class='value' title='First Name'>
<input type='text' name='firstName' value='Peter' id='firstName' maxlength='10'/>
</span>
</div>
<span class='name'><label for='value'>First Name:</label></span>
<span class='value' title='First Name'>
<input type='text' name='firstName' value='Peter' id='firstName' maxlength='10'/>
</span>
</div>
and look something like this: