diff --git a/extension/qfq/qfq/Constants.php b/extension/qfq/qfq/Constants.php index 72897ba0081dbe8f14a3055d2ed0fda0fa109fd9..d9024596133c9a3b160d2957ae1cb672d14a7e39 100644 --- a/extension/qfq/qfq/Constants.php +++ b/extension/qfq/qfq/Constants.php @@ -129,6 +129,7 @@ const ERROR_UNKNOWN_SQL_LOG_MODE = 1051; const ERROR_FORM_NOT_FOUND = 1052; const ERROR_DATE_TIME_FORMAT_NOT_RECOGNISED = 1053; const ERROR_SANATIZE_INVALID_VALUE = 1054; +const ERROR_REQUIRED_VALUE_EMPTY = 1055; // Store const ERROR_STORE_VALUE_ALREADY_CODPIED = 1100; diff --git a/extension/qfq/qfq/store/FillStoreForm.php b/extension/qfq/qfq/store/FillStoreForm.php index 4f29ef5a2c603a86a6ce608c17df2d813d94adf4..f01b6121aa9a9091f696b45cbc88695a0f601382 100644 --- a/extension/qfq/qfq/store/FillStoreForm.php +++ b/extension/qfq/qfq/store/FillStoreForm.php @@ -106,12 +106,18 @@ class FillStoreForm { continue; } + if ($formElement['mode'] === FE_MODE_REQUIRED) { + if (!isset($clientValues[$clientFieldName]) || ($clientValues[$clientFieldName] === '')) { + throw new UserFormException("Missing required value.", ERROR_REQUIRED_VALUE_EMPTY); + } + } + switch ($formElement['mode']) { - case FE_MODE_SHOW: case FE_MODE_REQUIRED: - if (isset($clientValues[$clientFieldName]) && ($clientValues[$clientFieldName] != '')) { + case FE_MODE_SHOW: + if (isset($clientValues[$clientFieldName])) { - // SELECT with multiple values, or Multi CHECKBOX are delivered as array: implode them + // SELECT MULTI or CHECKBOX MULTI: delivered as array - implode them. if (is_array($clientValues[$clientFieldName])) { // E.g. Checkboxes needs a 'HIDDEN' HTML input to detect 'unset' of values. These 'HIDDEN' element // needs to be removed, if there is at least one checkbox is checked (=submitted) @@ -121,18 +127,8 @@ class FillStoreForm { $clientValues[$clientFieldName] = implode(',', $clientValues[$clientFieldName]); } -// try { - $newValues[$formElement['name']] = Sanitize::sanitize($clientValues[$clientFieldName], - $formElement['checkType'], $formElement['checkPattern'], SANATIZE_EXCEPTION); -// } catch (UserFormException $e) { -// $msg = "Form element '" . $formElement['name'] . ' / ' . $formElement['label'] . "': " . $e->formatMessage(); -// throw new UserFormException($msg, ERROR_SANATIZE_INVALID_VALUE); -// } - } else { - if ($formElement['mode'] === FE_MODE_REQUIRED) { - throw new UserFormException("Missing required value for '" . $formElement['name'] . ' / ' . - $formElement['label'] . "'", ERROR_UNKNOWN_MODE); - } + $newValues[$formElement['name']] = Sanitize::sanitize($clientValues[$clientFieldName], + $formElement['checkType'], $formElement['checkPattern'], SANATIZE_EXCEPTION); } break;