Skip to content

Textarea Field

Overview

The textarea field type is designed for capturing multi-line textual input from users. It is ideal for longer content such as descriptions, comments, or detailed notes. The field provides options to set default content, adjust the visible size, and add placeholder text for improved user guidance.

Field Configuration

A simple implementation of the textarea field type:

php
array(
    'id'      => 'textarea_key',
    'type'    => 'textarea',
    'title'   => 'Textarea',
    'default' => 'Hello, It\'s CodexShaper!'
),

Specific Parameters

ParameterTypeDefaultDescription
defaultstring-Sets the default content of the textarea.

General Parameters

ParameterTypeDefaultDescription
idstring-Unique identifier for the field.
typestring-Defines the field type.
titlestring-The title displayed for the field.
subtitlestring-The text displayed under the title.
classstring-Field additional class.
data_typestringserializeDefines how data is stored (e.g., serialize).
namestring-Custom name for the field.
placeholderstringNot selectedPlaceholder text for the input.
attributesarrayarray()Custom HTML attributes.
beforestring-Content to display before the field.
afterstring-Content to display after the field.
descriptionstring-A detailed description of the field.
descstring-A short description, used if description is not set.
helpstring-Additional helper text for guidance. Usually show on the top right corner of the field.
errorstring-Error message to display when validation fails.
dependenciesarray-Show/Hide a field base on another field value.

Example Usages

Basic Textarea

php
array(
    'id'      => 'textarea_key',
    'type'    => 'textarea',
    'title'   => 'Textarea',
    'default' => 'Hello, It\'s CodexShaper!'
),

Extended Textarea with Additional Attributes

php
array(
    'id'           => 'textarea_key_extended',
    'type'         => 'textarea',
    'title'        => 'Extended Textarea',
    'default'      => 'Default multi-line content.',
    'placeholder'  => 'Enter your text here...',
    'description'  => 'This textarea field allows for multi-line text input.',
    'help'         => 'Ensure your content is well formatted.',
    'attributes'   => array(
        'autocomplete' => 'off',
        'rows'         => 5,
        'cols'         => 50,
    ),
),

Notes

  • The textarea field is best suited for multi-line text input.
  • Optional parameters like rows, cols, and placeholder help customize the appearance and user experience.