Have you seen our new video tutorials? Check it out!

Integer Field Type

The integer field type provides a whole number input.

Introduction

anomaly.field_type.integer

The integer field type provides a basic HTML input that restricts input to integer values between an optional range.

Configuration

Below is the full configuration available with defaults values:

"example" => [
    "type"   => "anomaly.field_type.integer",
    "config" => [
        "default_value" => null,
        "separator" => ",",
        "point"     => ".",
        "decimals"  => 2,
        "step"      => 1,
        "min"       => null,
        "max"       => null,
    ]
]
Configuration
Key Example Description

default_value

25.5

The default value.

separator

The thousands separator.

point

,

The decimal point.

decimals

4

The decimal precision to enforce.

step

5

The numerical interval between value steps.

min

0.01

The minumum value allowed.

max

99.99

The maximum value allowed.

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 integer field type value with any valid integer.

$entry->example = 10;

Basic Output

The integer field type returns null or the integer value.

$entry->example; // 10

Presenter Output

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

IntegerFieldTypePresenter::format()

The format method returns the formatted number string according to configuration.

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

IntegerFieldTypePresenter::currency()

The currency method returns the currency formatted value.

Returns: string
Arguments
Key Required Type Default Description

$currency

false

string

The currency field value or default configured currency.

The currency to format for.

$field

false

string

currency

The slug of the currency field.

Example
$decorated->example->currency();
Twig
{{ decorated.example.currency() }}