objects

FieldValue

A field as one record holds it: the value with its definition (type, label, options) and where it lives (context).

Never persisted, never registry-indexed. What it can do comes from its FieldType.

$fieldValue Phlat\FieldValue 11 methods
Properties (9)
$fieldValue->name string readonly
$fieldValue->type string readonly
$fieldValue->label string readonly
$fieldValue->options array readonly
$fieldValue->context array readonly
$fieldValue->value mixed readonly
$fieldValue->labelled bool readonly
$fieldValue->errors array readonly
$fieldValue->render string readonly
Show
  • decode The value as templates use it, decoded by the field's type.
  • editTemplate Path of this field type's admin edit template, or null if it has none.
  • empty Whether the field holds nothing.
  • encode A submitted value as it would be stored.
  • filled This field holding a posted value in place of the stored one, with the errors it was refused for - what a form shows again after a refused save.
  • of A field built in code rather than read from a template, for a form whose values aren't a record's content - a page's settings, a password change, a filter.
  • preview A short text summary of the value, as the admin lists it.
  • previewTemplate Path of this field type's optional preview template, or null.
  • render The field as HTML, through its render.latte.
  • type The FieldType that encodes, decodes and validates this field.
  • validate The errors a submitted value fails on: its type's checks, then `required`, `min_length` and `max_length`.

Methods

$fieldValue->decode(): mixed

The value as templates use it, decoded by the field's type.

Returns mixed

phlat/src/FieldValue.php:64
$fieldValue->editTemplate(): ?string

Path of this field type's admin edit template, or null if it has none.

Returns ?string

phlat/src/FieldValue.php:52
$fieldValue->empty(): bool

Whether the field holds nothing.

Returns bool

phlat/src/FieldValue.php:76
$fieldValue->encode(mixed $raw): mixed

A submitted value as it would be stored.

Parameters (1)
$raw mixed

Returns mixed

phlat/src/FieldValue.php:70
$fieldValue->filled(mixed $value, array $errors = []): self

This field holding a posted value in place of the stored one, with the errors it was refused for - what a form shows again after a refused save.

Parameters (2)
$value mixed
$errors array = []

Returns self

phlat/src/FieldValue.php:40

of

static
FieldValue::of(App $app, string $name, string $type, string $label, mixed $value, array $options = [], array $context = []): self

A field built in code rather than read from a template, for a form whose values aren't a record's content - a page's settings, a password change, a filter.

Parameters (7)
$app App
$name string
$type string
$label string
$value mixed
$options array = []
$context array = []

Returns self

phlat/src/FieldValue.php:34
$fieldValue->preview(): string

A short text summary of the value, as the admin lists it.

Returns string

phlat/src/FieldValue.php:82
$fieldValue->previewTemplate(): ?string

Path of this field type's optional preview template, or null.

Returns ?string

phlat/src/FieldValue.php:58
$fieldValue->render(): string

The field as HTML, through its render.latte.

Returns string

phlat/src/FieldValue.php:127
$fieldValue->type(): FieldType

The FieldType that encodes, decodes and validates this field.

Returns FieldType

phlat/src/FieldValue.php:46
$fieldValue->validate(mixed $raw): array

The errors a submitted value fails on: its type's checks, then `required`, `min_length` and `max_length`.

Parameters (1)
$raw mixed

Returns array

phlat/src/FieldValue.php:88