Presenter Output

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

BooleanFieldTypePresenter::isTrue()

The isTrue method returns whether the value is true or not. This is a shortcut for the is(true) method.

Returns: boolean
Example
$decorated->example->isTrue();
Twig
{% if decorated.example.isTrue() %}
  Yep!
{% endif %}

Presenter processing means you can simply do this:

{% if decorated.example.true %}
  Yep!
{% endif %}

BooleanFieldTypePresenter::isFalse()

The isFalse method returns whether the value is false or not. If the value is false this method will return true. This is a shortcut for the is(false) method.

Returns: boolean
Example
$decorated->example->isTrue();
Twig
{% if decorated.example.isFalse() %}
  Oh crap...
{% endif %}

Presenter processing means you can simply do this:

{% if decorated.example.false %}
  Yep!
{% endif %}

BooleanFieldTypePresenter::is()

The is method returns whether the value matches the test value.

Returns: boolean
Arguments
Key Required Type Default Description

$test

true

mixed

none

The boolean or filterable text to test.

Example
if ($decorated->example->is(true)) {
    echo "Yes!";
}
Twig
{% if decorated.example.is(true) %}
  Yep!
{% endif %}

BooleanFieldTypePresenter::icon()

The icon method returns an icon representing the value.

Returns: string
Arguments
Key Required Type Default Description

$size

false

string

sm

The size of the icon. Valid options are sm, md, and lg.

Example
$decorated->example->icon('lg'); // <i class="text-{color} fa fa-check fa-lg"></i>
Twig
{{ decorated.example.icon(); // <i class="text-{color} fa fa-check fa-sm"></i>

BooleanFieldTypePresenter::color()

The color method returns the configured state color based on the value.

Returns: string
Example
$decorated->example->color();
Twig
{{ decorated.example.color() }}

BooleanFieldTypePresenter::label()

The label method returns a label of the configured state color based on the value.

Returns: string
Example
$decorated->example->label();
Twig
{{ decorated.example.label() }}

BooleanFieldTypePresenter::text()

The text method returns text based on the value.

Returns: string
Arguments
Key Required Type Default Description

$on

false

string

The configured on_text.

Text for "on" state.

$ff

false

string

The configured off_text.

Text for "off" state.

Example
$decorated->example->text('YAS!', 'DRAT!');
Twig
{{ decorated.example.text('YAS!', 'DRAT!') }}

BooleanFieldTypePresenter::toggle()

The toggle method returns an ajax input switch that will update the value.

Returns: string
Example
$decorated->example->toggle();
Twig
Status: {{ decorated.example.toggle()|raw }}

This method is great for use in table columns!

protected $columns = [
    'entry.example.toggle' => [
        'is_safe' => true,
    ],
];