Skip to content

Status Field (PRO)

A read-only badge computed from another field. Nobody fills it in — you describe the rules once, and the value follows the source.

Settings:

SettingWhat it does
Source fieldThe field whose value is examined
Status rulesRows of Up to (≤) / Status / Color

Rules are ordered and the first match wins. For a numeric source a row matches when the value is less than or equal to its threshold; for a text source, when the value is equal to it. If nothing matched, the last row is used — which is what makes it the "and above" bucket.

Up to (≤)StatusColor
0Out of stockdanger
10Running lowwarning
In stocksuccess

Colours are success, warning, danger and info; anything else renders grey.

Output: the value is a pair, a label and a colour.

html
<span class="badge badge-{$stock.color}">{$stock.label}</span>

The status is computed on the server, not in the browser

The badge updates live as you type, but the browser submits nothing — the value is recomputed from the same rules in PHP on save. So a row written through the REST API, a seed or an import gets the same status as one saved by hand, and the stored value can never drift away from its source.

© PageBlocks 2019-present