Commit c24c9d9f authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge branch 'UploadRequiredCheckFailed' into 'develop'

Fixes #12398. All combinations of new/existing upload should now be handled correctly.

See merge request !336
parents 09c80ddf 23934a17
Pipeline #5158 passed with stages
in 3 minutes and 48 seconds
......@@ -750,13 +750,32 @@ class Save {
if (isset($formElement[FE_ACCEPT_ZERO_AS_REQUIRED]) && $formElement[FE_ACCEPT_ZERO_AS_REQUIRED] != '0' &&
isset($clientValues[$formElement[FE_NAME]]) && $clientValues[$formElement[FE_NAME]] == '0') {
$mode = 'fake'; // The next if() should never be true.
continue;
}
// Upload needs special action to check for empty.
if ($mode == FE_MODE_REQUIRED && $formElement[FE_TYPE] == FE_TYPE_UPLOAD) {
// Get new upload state
$statusUpload = $this->store->getVar($clientValues[$formElement[FE_NAME]] ?? '', STORE_EXTRA);
// Check if there is a new upload
if ($statusUpload[FILES_TMP_NAME] != '') {
continue;// Upload given: continue with next FE
}
// Check if there is no already given upload or such upload has not to be deleted
if (empty($this->store->getVar($formElement[FE_NAME], STORE_RECORD)) || ($statusUpload[FILES_FLAG_DELETE] ?? 0) == '1') {
// Fake to trigger the next if( .. empty...)
$clientValues[$formElement[FE_NAME]] = '';
}
}
if ($mode == FE_MODE_REQUIRED && empty($clientValues[$formElement[FE_NAME]])) {
$flagAllRequiredGiven = 0;
if ($reportRequiredFailed) {
throw new \UserFormException("Missing required value: " . $formElement[FE_LABEL], ERROR_REQUIRED_VALUE_EMPTY);
$name = ($formElement[FE_LABEL] == '') ? $formElement[FE_NAME] : $formElement[FE_LABEL];
throw new \UserFormException("Missing required value: $name", ERROR_REQUIRED_VALUE_EMPTY);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment