Introduction

anomaly.field_type.textarea

The textarea field type provides a flexible HTML textarea input.

Configuration

Below is the full configuration available with defaults values:

"example" => [
    "type"   => "anomaly.field_type.text",
    "config" => [
        "rows"          => 6,
        "min"           => null,
        "max"           => null,
        "default_value" => null,
    ]
]
Configuration
Key Example Description

rows

7

The number of rows high the textarea should be.

min

100

The minimum length of text allowed.

max

250

The maximum length of text allowed.

default_value

Some Example Text

The default value.

Usage

This section will show you how to use the field type via API and in the view layer.

Setting Values

You can set the textarea field type value with any compatible value.

$entry->example = "Example Text";

Basic Output

The textarea field type returns null or the string value.

$entry->example; // Test String

Presenter Output

This section will show you how to use the decorated value provided by the \Anomaly\TextareaFieldType\TextareaFieldTypePresenter class.

TextareaFieldTypePresenter::yaml()

The yaml method parses the value as YAML.

Returns: mixed
Example
$decorated->example->yaml()['some_key'];
Twig
{{ decorated.example.yaml().some_key }}

TextareaFieldTypePresenter::lines()

The lines method returns an array of lines from within the value.

Returns: array
Arguments
Key Required Type Default Description

$limit

false

integer

9999

The maximum length of the value allowed into the explode function.

Example
echo count($decorated->example->lines());
Twig
<ul>
	<li>
		{% for line in decorated.example.lines() %}
			{{ line }}
		{% endfor %}
	</li>
</ul>

TextareaFieldTypePresenter::line()

The line method returns a specific line value.

Returns: string
Arguments
Key Required Type Default Description

$line

true

integer

1

The line you would like to return.

Example
$decorated->example->line(1); // Street address
$decorated->example->line(2); // City, State, ZIP
Twig
{{ decorated.example.line(1) }} // Street address
{{ decorated.example.line(2) }} // City, State, ZIP

TextareaFieldTypePresenter::limit()

The limit method returns a truncated and capped string if longer than the specified limit.

Returns: string
Arguments
Key Required Type Default Description

$limit

true

integer

100

The maximum length allowed before truncating and finishing with the string end.

$end

true

string

...

The ending that will be appended to the string if truncated.

Example
$decorated->example->limit(); // 100 characters...
Twig
{{ decorated.example.limit() }} // 100 characters...