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.
Entry::text('name', 'Name');
Entry::date('joined_at', 'Member since', 'j F Y');
Entry::badge('status', 'Status', ['active' => 'success', 'banned' => 'danger']);Methods
text
static text(string $field, string $label): selfemail
static email(string $field, string $label): selfphone
static phone(string $field, string $label): selfurl
static url(string $field, string $label, ?string $text = null): selfA link to the value (relative, http or https; other URLs are shown as text), or to $text when given.
date
static date(string $field, string $label, string $format = 'Y-m-d'): selfA date (a DateTimeInterface or an ISO 8601 string), in a <time> element.
dateTime
static dateTime(string $field, string $label, string $format = 'Y-m-d H:i'): selfnumber
static number(string $field, string $label, int $decimals = 0, string $prefix = '', string $suffix = '', string $decimalSeparator = '.', string $thousandsSeparator = ','): selfboolean
static boolean(string $field, string $label): selfYes or No (the record view's labels), with a mark.
badge
static badge(string $field, string $label, array $colors = []): selfThe value in a badge, colored by value: ['active' => 'success']; others are secondary.
list
static list(string $field, string $label, bool $badges = false): selfA list of values (an array), one per line, or as badges.
image
static image(string $field, string $label, string $alt = ''): selfA picture from the value's URL (relative, http or https). Without $alt, it is decorative.
format
format(callable $format): selfShows what the callback returns: a string is escaped text, a Stringable is HTML.
$value: , mixed $record): (string|Stringable) $format
placeholder
placeholder(string $placeholder): selfShown when the value is empty (null, '' or []), instead of the record view's.
help
help(string $help): selfA short text under the value.
span
span(int $span): selfThe columns the entry spans in its section (1 by default).
getField
getField(): stringgetLabel
getLabel(): stringgetSpan
getSpan(): intgetHelp
getHelp(): ?stringrenderValue
renderValue(mixed $value, mixed $record, array $labels): stringThe value's HTML.