Skip to content

Caelrik\Ui\Components\RecordView ​

Entry ​

final class Caelrik\Ui\Components\RecordView\Entry

One field of a record view: its label and its value, shown as text, a link, a date, a number, a yes or no, a badge, a list or a picture.

php
Entry::text('name', 'Name');
Entry::date('joined_at', 'Member since', 'j F Y');
Entry::badge('status', 'Status', ['active' => 'success', 'banned' => 'danger']);

Methods ​

text ​

php
static text(string $field, string $label): self

email ​

php
static email(string $field, string $label): self

phone ​

php
static phone(string $field, string $label): self

url ​

php
static url(string $field, string $label, ?string $text = null): self

A link to the value (relative, http or https; other URLs are shown as text), or to $text when given.

date ​

php
static date(string $field, string $label, string $format = 'Y-m-d'): self

A date (a DateTimeInterface or an ISO 8601 string), in a <time> element.

dateTime ​

php
static dateTime(string $field, string $label, string $format = 'Y-m-d H:i'): self

number ​

php
static number(string $field, string $label, int $decimals = 0, string $prefix = '', string $suffix = '', string $decimalSeparator = '.', string $thousandsSeparator = ','): self

boolean ​

php
static boolean(string $field, string $label): self

Yes or No (the record view's labels), with a mark.

badge ​

php
static badge(string $field, string $label, array $colors = []): self

The value in a badge, colored by value: ['active' => 'success']; others are secondary.

list ​

php
static list(string $field, string $label, bool $badges = false): self

A list of values (an array), one per line, or as badges.

image ​

php
static image(string $field, string $label, string $alt = ''): self

A picture from the value's URL (relative, http or https). Without $alt, it is decorative.

format ​

php
format(callable $format): self

Shows what the callback returns: a string is escaped text, a Stringable is HTML.

  • $value: , mixed $record): (string|Stringable) $format

placeholder ​

php
placeholder(string $placeholder): self

Shown when the value is empty (null, '' or []), instead of the record view's.

help ​

php
help(string $help): self

A short text under the value.

span ​

php
span(int $span): self

The columns the entry spans in its section (1 by default).

getField ​

php
getField(): string

getLabel ​

php
getLabel(): string

getSpan ​

php
getSpan(): int

getHelp ​

php
getHelp(): ?string

renderValue ​

php
renderValue(mixed $value, mixed $record, array $labels): string

The value's HTML.

Released under the MIT License.