Skip to content
Snippets Groups Projects
Commit 8dfadeca authored by Carsten  Rose's avatar Carsten Rose
Browse files

FillStoreForm.php, Constants.php: fixed bug that empty values are not stored.

parent 2d0d6fc3
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment