From a72df48591e284231b2fd0bb4db793a6f04e2de9 Mon Sep 17 00:00:00 2001 From: Ivan Bochkarev Date: Thu, 23 Jul 2026 12:00:28 +0600 Subject: [PATCH] fix: trim all whitespace when splitting &validate fields trim(ltrim($v), ' ') only strips leading whitespace and trailing spaces, so a validator definition ending with a newline (e.g. the last line of a multi-line &validate chunk) keeps that newline as part of its validator name. method_exists() then fails to match the validator, and validation for that field is silently skipped. Use trim($v) to strip whitespace, including newlines, from both ends. Fixes #276 --- core/components/formit/src/FormIt/Validator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/components/formit/src/FormIt/Validator.php b/core/components/formit/src/FormIt/Validator.php index 21f96b7..c062bee 100644 --- a/core/components/formit/src/FormIt/Validator.php +++ b/core/components/formit/src/FormIt/Validator.php @@ -108,7 +108,7 @@ public function validateFields(Dictionary $dictionary, $validationFields = '', $ $validationFields = explode($validationSeparator, $validationFields); $fieldValidators = array(); foreach ($validationFields as $idx => $v) { - $v = trim(ltrim($v),' '); /* allow multi-line definitions */ + $v = trim($v); /* strip all whitespace, including newlines, to allow multi-line definitions */ $key = explode(':',$v); /* explode into list separated by : */ if (!empty($key[0])) { $field = $key[0];