Back
textAreaTag()
Builds and returns an HTML <textarea>
form control based only on the supplied field name, rather than being tied to a specific model object. It is useful when you want to generate a standalone text area not bound to an object, such as for ad-hoc forms, search boxes, or generic input fields. You can set the initial content of the textarea, add a label, and pass in additional attributes like class, id, or rel. Options are also available to control label placement, prepend or append HTML wrappers, and configure whether output should be encoded for XSS protection.
1. Basic textarea with label
#textAreaTag(label="Description", name="description", content=params.description)#
2. Textarea with custom attributes
#textAreaTag(
label="Notes",
name="notes",
class="form-control",
id="notesBox",
rows="6",
cols="60"
)#
3. Textarea without label
#textAreaTag(name="feedback", content="Enter your feedback here...")#
4. Custom label placement
#textAreaTag(
label="Comments",
name="comments",
labelPlacement="before"
)#
5. Prepending and appending HTML
#textAreaTag(
label="Message",
name="message",
prepend="<div class='input-wrapper'>",
append="</div>"
)#
Copied!