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 12 methods
Properties (10)
$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
$fieldValue->renders array 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: its page's view's render of it, else its own render.{view}.latte, else its render.latte, else its fieldtype's.
  • templateFields The sub-fields this field declares (`fields`, as an object or collection does) as [name => Field].
  • 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:78
$fieldValue->editTemplate(): ?string

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

Returns ?string

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

Whether the field holds nothing.

Returns bool

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

A submitted value as it would be stored.

Parameters (1)
$raw mixed

Returns mixed

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

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 FieldValue

phlat/src/FieldValue.php:44

of

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

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 FieldValue

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

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

Returns string

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

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

Returns ?string

phlat/src/FieldValue.php:72
$fieldValue->render(array $params = []): string

The field as HTML: its page's view's render of it, else its own render.{view}.latte, else its render.latte, else its fieldtype's.

Parameters (1)
$params array = []

Returns string

phlat/src/FieldValue.php:141
$fieldValue->templateFields(): array<string, Field>

The sub-fields this field declares (`fields`, as an object or collection does) as [name => Field].

Returns array<string, Field>

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

The FieldType that encodes, decodes and validates this field.

Returns FieldType

phlat/src/FieldValue.php:60
$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:102