diff --git a/inc/field/checkboxesfield.class.php b/inc/field/checkboxesfield.class.php index 07cdc072e..eeb7fdde0 100644 --- a/inc/field/checkboxesfield.class.php +++ b/inc/field/checkboxesfield.class.php @@ -204,9 +204,19 @@ public function isValidValue($value): bool { foreach ($value as $item) { if (trim($item) == '') { + Session::addMessageAfterRedirect( + sprintf(__('Empty values are not allowed: %s', 'formcreator'), $this->getTtranslatedLabel()), + false, + ERROR + ); return false; } if (!in_array($item, $this->getAvailableValues())) { + Session::addMessageAfterRedirect( + sprintf(__('This value %1$s is not alowed: %2$s', 'formcreator'), $item, $this->getTtranslatedLabel()), + false, + ERROR + ); return false; } } diff --git a/inc/field/radiosfield.class.php b/inc/field/radiosfield.class.php index 4026d1179..5d8049ed2 100644 --- a/inc/field/radiosfield.class.php +++ b/inc/field/radiosfield.class.php @@ -204,8 +204,18 @@ public function isValidValue($value): bool { if ($value == '') { return true; } + $value = trim($value); - return in_array($value, $this->getAvailableValues()); + if (!in_array($value, $this->getAvailableValues())) { + Session::addMessageAfterRedirect( + sprintf(__('This value %1$s is not allowed: %2$s', 'formcreator'), $value, $this->getTtranslatedLabel()), + false, + ERROR + ); + return false; + } + + return true; } public static function canRequire(): bool { diff --git a/inc/field/selectfield.class.php b/inc/field/selectfield.class.php index 9296b24cc..68e6b402b 100644 --- a/inc/field/selectfield.class.php +++ b/inc/field/selectfield.class.php @@ -118,7 +118,16 @@ public function isValidValue($value): bool { return true; } $value = trim($value); - return in_array($value, $this->getAvailableValues()); + if (!in_array($value, $this->getAvailableValues())) { + Session::addMessageAfterRedirect( + sprintf(__('This value %1$s is not allowed: %2$s', 'formcreator'), $value, $this->getTtranslatedLabel()), + false, + ERROR + ); + return false; + } + + return true; } public function equals($value): bool {