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

Implements #9617. a) formModeGlobal=requiredShowOnly set's the form attribute....

Implements #9617. a) formModeGlobal=requiredShowOnly set's the form attribute. The new STORE_VAR 'allRequiredGiven' is set
parent a7a40744
Pipeline #2724 passed with stages
in 3 minutes and 1 second
......@@ -593,6 +593,10 @@ class BuildFormBootstrap extends AbstractBuildForm {
$attribute['class'] = 'form-horizontal';
$attribute['data-toggle'] = 'validator';
if ($this->store::getVar(F_MODE_GLOBAL, STORE_SIP) == F_MODE_REQUIRED_SHOW_ONLY) {
$attribute['data-required-show-only'] = 'true';
}
if (isset($this->formSpec[F_SAVE_BUTTON_ACTIVE]) && $this->formSpec[F_SAVE_BUTTON_ACTIVE] != '0') {
$attribute[DATA_ENABLE_SAVE_BUTTON] = 'true';
}
......
......@@ -723,6 +723,7 @@ const VAR_FILENAME_BASE = 'filenameBase'; // Original filename of an uploaded fi
const VAR_FILENAME_EXT = 'filenameExt'; // Extension of the original filename of an uploaded file, .
const VAR_FILE_MIME_TYPE = 'mimeType';
const VAR_FILE_SIZE = 'fileSize';
const VAR_ALL_REQUIRED_GIVEN = 'allRequiredGiven'; // 0 if at least one FE is required and value is missing, else 1.
// PHP class Typeahead
......@@ -1008,6 +1009,7 @@ const F_TYPEAHEAD_LDAP_SEARCH_PER_TOKEN = 'typeAheadLdapSearchPerToken';
const F_MODE = 'mode';
const F_MODE_READONLY = 'readonly';
const F_MODE_REQUIRED_OFF = 'requiredOff';
const F_MODE_REQUIRED_SHOW_ONLY = 'requiredShowOnly';
const F_MODE_GLOBAL = 'formModeGlobal';
const F_SAVE_BUTTON_ACTIVE = 'saveButtonActive';
......
......@@ -544,10 +544,13 @@ class Save {
*/
public function checkRequiredHidden() {
$requiredOff = ($this->store->getVar(F_MODE_GLOBAL, STORE_SIP) == F_MODE_REQUIRED_OFF);
$formModeGlobal = $this->store->getVar(F_MODE_GLOBAL, STORE_SIP);
$reportRequiredFailed = ($formModeGlobal != F_MODE_REQUIRED_OFF && $formModeGlobal != F_MODE_REQUIRED_SHOW_ONLY);
$clientValues = $this->store::getStore(STORE_FORM);
$flagAllRequiredGiven = 1;
foreach ($this->feSpecNative AS $key => $formElement) {
// Do not check retype slave FE.
......@@ -569,8 +572,11 @@ class Save {
$mode = 'fake'; // The next if() should never be true.
}
if (!$requiredOff && $mode == FE_MODE_REQUIRED && empty($clientValues[$formElement[FE_NAME]])) {
throw new \UserFormException("Missing required value: " . $formElement[FE_LABEL], ERROR_REQUIRED_VALUE_EMPTY);
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);
}
}
if ($mode == FE_MODE_HIDDEN) {
......@@ -578,6 +584,9 @@ class Save {
$this->store::unsetVar($formElement[FE_NAME], STORE_FORM);
}
}
// Save 'allRequiredGiven in STORE_VAR
$this->store::setVar(VAR_ALL_REQUIRED_GIVEN, $flagAllRequiredGiven, STORE_VAR, true);
}
/**
......
Markdown is supported
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