Skip to content

PassFieldContent

Raxos\Wallet\Apple\Component\PassFieldContent is the abstract base class for the six field kinds shown on a pass. Each concrete subclass names the slot the field fills.

php
abstract readonly class PassFieldContent implements ComponentInterface

Implements Raxos\Contract\Wallet\ComponentInterface (see raxos/contract).

Constructor

ParameterTypeDescription
keystringUnique key for the field.
valuestring|intThe displayed value.
attributedValuestring|nullValue with limited HTML markup.
changeMessagestring|nullMessage shown when the value changes.
currencyCodestring|nullISO currency code for numeric values.
dataDetectorTypesDataDetectorType[]|nullDetectors to apply to the value.
dateStyleDateStyle|nullHow to format a date value.
ignoresTimeZonebool|nullIgnore the device time zone for dates.
isRelativebool|nullDisplay the date relative to now.
labelstring|nullLabel shown above the value.
numberStyleNumberStyle|nullHow to format a numeric value.
textAlignmentTextAlignment|nullAlignment of the field.
timeStyleDateStyle|nullHow to format the time portion of a date value.

Methods

jsonSerialize(): array

Returns the field data, filtering out null and empty values.

Subclasses

The six concrete field classes add no behavior beyond naming the slot:

  • PrimaryField
  • SecondaryField
  • AuxiliaryField
  • AdditionalInfoField
  • HeaderField
  • BackField

Example

php
<?php
declare(strict_types=1);

use Raxos\Wallet\Apple\Component\SecondaryField;
use Raxos\Wallet\Apple\Enum\{DateStyle, TextAlignment};

$field = new SecondaryField(
    key: 'valid-until',
    value: '2026-12-31',
    label: 'Valid until',
    dateStyle: DateStyle::MEDIUM,
    textAlignment: TextAlignment::RIGHT
);

See also