{textarea}

A text area with its label that refills from what its form sent and shows the error validation found for it.

Forms and security Single tags

Syntax

{textarea 'message'}
{textarea 'message', label='Message', value='', id='msg', rows=6, required}
{textarea 'message', label='Message', rows=6, rules='required|max:2000'}

Parameters

name
The field name - required.

Options

label
A <label for> before the text area, and the word its error message uses.
value
The text before anything was sent, escaped.
id
The id, by default the name.
rules
The field's rules - required|max:2000 - read from the page's own template and checked before its PHP runs. Only in a named {form} of the page itself.

Description

{textarea} is {input} for a multi-line text: a <label for> when label= is given, then a <textarea> with the name and an id. The text inside is value= before a post and what was sent after a post of its {form} - escaped both times, so markup in it stays text.

The tag takes label, value, id and rules; every other item - rows=, cols=, maxlength=, placeholder=, a bare required - is an attribute of the text area.

The error the validation found for it follows the text area as for an input, with aria-invalid and aria-describedby. rules= follows the same rules as on {input}: only in a named form written in the page's own template.

Examples

A text area with a label

value= is the text before anything was sent - escaped, so markup in it stays text.

Templateexamples/textarea/1-basic.pad
{textarea 'note', label='Note', rows=4, cols=40, value='Deliver after <5 pm> & ring twice'}
Resultopen alone

In a form

Inside a {form} the text area refills from what that form sent; other items are attributes.

Templateexamples/textarea/2-form.pad
{form 'feedback', method='get'}
  {input 'subject', label='Subject', value='Hello'}
  {textarea 'body', label='Your message', rows=5, maxlength=500, placeholder='Write here', required}
  <button>Send</button>
{/form}
Resultopen alone

Rules on a text area

rules= is checked before the page's PHP runs; a post that broke it renders the form again, refilled, the message under the field.

Templateexamples/textarea/3-rules.src
{form 'contact', error}
  {input 'email', type='email', label='E-mail', rules='required|email'}
  {textarea 'message', label='Message', rows=6, rules='required|max:2000'}
  <button>Send</button>
{/form}

See also

  • {input} A form field with its label that refills from what its form sent and shows the error validation found for it.
  • {form} A form that posts back to the page, carrying the session's CSRF token and its own name, its fields refilling when it came back.
  • {attrs} Writes HTML attributes from values - quoted and escaped, a true boolean attribute bare, a false one left out.