N.B. All text represented by a <placeholder> should be appropriately replaced according to requirements. The field_type_idmust match the id of a field type and the field_formatter_id should match the default formatter specified in the field type (see Part 1 of this article).

d) Add field formatter class

Create the field formatter class as follows:

class <field_formatter_name> extends FormatterBase {

}

N.B. The <field_formatter_name> must match the name of this file (case-sensitive).

The field formatter class needs to contain the viewElements() function that defines how the field will be output: