Custom Column & Field Display
Format grid columns and form fields without touching the underlying data - patterns, truncation, tooltips, highlighting, and read-only popups.
Composing a display pattern
->column_pattern($field, $pattern) replaces a column's displayed value with a template that can pull in OTHER columns from the same row via {placeholder}. Display-only - editing the field (inline or in the form) still shows/saves its own real value.
$xcrud->column_pattern('customerNumber', 'Customer #{customerNumber} - {city}');
| Parameter | Type | Default | Description |
|---|---|---|---|
$field | string | - | Column whose displayed value is replaced |
$pattern | string | - | Template text; {placeholder} references any whitelisted column in the row |
Truncating long text
->column_cut($field, $length) truncates a column's displayed text to $length characters, adding an ellipsis when cut. The full value is still available as a hover tooltip, and inline editing always shows the untruncated value.
$xcrud->column_cut('description', 60);
| Parameter | Type | Default | Description |
|---|---|---|---|
$field | string | - | Column to truncate |
$length | int | - | Max characters shown before the ellipsis |
Styling and hints
->column_class($field, $class) adds an extra CSS class to a column's header and every cell in it (e.g. right-aligning a numeric column). ->column_tooltip($field, $text) adds a hover hint icon next to a column header. ->column_width($field, $width) sets a fixed column width (e.g. '200px' or '20%').
$xcrud->column_class('creditLimit', 'text-right');
$xcrud->column_tooltip('creditLimit', 'Maximum outstanding balance allowed.');
$xcrud->column_width('creditLimit', '140px');
| Method | Parameters | Description |
|---|---|---|
column_class | $field, $class | Extra CSS class on the column's header and cells |
column_tooltip | $field, $text | Hover hint on the column header |
column_width | $field, $width | Fixed column width |
->field_tooltip($field, $text) is the form-side equivalent - a hover hint next to a form field's own label instead of a grid header.
$xcrud->field_tooltip('creditLimit', 'Maximum outstanding balance allowed.');
Conditional highlighting
->highlight($field, $operator, $value, $class) colors a single cell's background when its value matches a comparison. ->highlight_row($field, $operator, $value, $class) does the same for the entire row. $operator accepts symbols (=, !=, >, >=, <, <=) or codes (eq, neq, gt, gte, lt, lte, contains, starts, ends).
$xcrud->highlight('creditLimit', 'gt', '100000', 'xcrud-hl-warn');
$xcrud->highlight_row('status', 'eq', 'overdue', 'xcrud-hl-danger');
| Parameter | Type | Default | Description |
|---|---|---|---|
$field | string | - | Column the comparison reads |
$operator | string | - | Comparison operator (symbol or code) |
$value | string | - | Value to compare against |
$class | string | - | CSS class applied when the comparison matches |
Multiple rules can match the same cell/row - classes stack rather than replace each other. See Custom Cell Rendering: Badges & Avatars for pairing highlighting with badge/avatar markup.
Read-only popup for long values
->modal($field) makes a non-editable column's cell open its full value in a read-only popup when clicked, instead of doing nothing or triggering inline edit.
$xcrud->modal('description');