From 99f1a61cd08fbf39005b9c3346e1550ab0dafda0 Mon Sep 17 00:00:00 2001 From: Ben Thomson Date: Fri, 23 Oct 2020 17:30:42 +0800 Subject: [PATCH] Create example of data table with computed column --- controllers/Countries.php | 40 ++++++++++++++++++++++++++++++++++++++ models/country/fields.yaml | 6 ++++++ 2 files changed, 46 insertions(+) diff --git a/controllers/Countries.php b/controllers/Countries.php index 084e2fb..16f9525 100644 --- a/controllers/Countries.php +++ b/controllers/Countries.php @@ -1,5 +1,6 @@ = 30) { + return 'Extremely Dangerous'; + } else if ($dangerScore >= 20) { + return 'Dangerous'; + } else if ($dangerScore >= 15) { + return 'Maintain Caution'; + } else if ($dangerScore >= 10) { + return 'Keep Alert'; + } else if ($dangerScore >= 5) { + return 'Low Risk'; + } else { + return 'No Risk'; + } + } } diff --git a/models/country/fields.yaml b/models/country/fields.yaml index 5c554f4..21c6687 100644 --- a/models/country/fields.yaml +++ b/models/country/fields.yaml @@ -124,12 +124,18 @@ tabs: validation: required: message: Please select a type + danger: + title: Danger Index + type: computed + dependsOn: [rating, type] + callback: onGetDangerComputedValue locations: tab: Related label: Locations prompt: Add new location span: full type: repeater + minItems: 1 form: fields: country: