Commit ab1f166a authored by Carsten  Rose's avatar Carsten Rose

Fixes #9858. Feature Form.parameter: replace 'mode' by 'formModeGlobal'

parent 6c1e1d49
Pipeline #3115 passed with stages
in 2 minutes
......@@ -2302,8 +2302,8 @@ abstract class AbstractBuildForm {
];
// Inherit current F_MODE
if ($this->formSpec[F_MODE] != '') {
$queryStringArray[F_MODE_GLOBAL] = $this->formSpec[F_MODE];
if ($this->formSpec[F_MODE_GLOBAL] != '') {
$queryStringArray[F_MODE_GLOBAL] = $this->formSpec[F_MODE_GLOBAL];
}
// In case the subrecord FE is set to 'readonly': subforms will be called with formModeGlobal=readonly
......
......@@ -586,6 +586,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
* @throws \UserReportException
*/
public function getFormTag() {
......
......@@ -1010,7 +1010,6 @@ const F_TYPEAHEAD_LDAP_SEARCH = 'typeAheadLdapSearch';
const F_TYPEAHEAD_LDAP_SEARCH_PREFETCH = 'typeAheadLdapSearchPrefetch';
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_OFF_BUT_MARK = 'requiredOffButMark';
......
......@@ -855,8 +855,8 @@ class Support {
$formElement[FE_MODE] = $formElement[FE_MODE_SQL];
}
if (isset($formSpec[F_MODE])) {
$formElement[FE_MODE] = self::applyFormModeToFormElement($formElement[FE_MODE], $formSpec[F_MODE]);
if (isset($formSpec[F_MODE_GLOBAL])) {
$formElement[FE_MODE] = self::applyFormModeToFormElement($formElement[FE_MODE], $formSpec[F_MODE_GLOBAL]);
}
// set typeAheadPedantic
......
......@@ -448,7 +448,7 @@ class QuickFormQuery {
$recordDirty = array();
$rcLockFound = $dirty->getCheckDirty($this->formSpec[F_TABLE_NAME], $recordId, $recordDirty, $msg);
if (($rcLockFound == LOCK_FOUND_CONFLICT || $rcLockFound == LOCK_FOUND_OWNER) && $recordDirty[F_DIRTY_MODE] == DIRTY_MODE_EXCLUSIVE) {
$this->formSpec[F_MODE] = F_MODE_READONLY;
$this->formSpec[F_MODE_GLOBAL] = F_MODE_READONLY;
}
}
......@@ -1435,7 +1435,6 @@ class QuickFormQuery {
Support::setIfNotSet($formSpec, F_SUBMIT_BUTTON_TEXT, '');
Support::setIfNotSet($formSpec, F_BUTTON_ON_CHANGE_CLASS, '');
Support::setIfNotSet($formSpec, F_LDAP_USE_BIND_CREDENTIALS, '');
Support::setIfNotSet($formSpec, F_MODE, '');
Support::setIfNotSet($formSpec, F_DB_INDEX, $this->store->getVar(F_DB_INDEX, STORE_SYSTEM));
Support::setIfNotSet($formSpec, F_ENTER_AS_SUBMIT, $this->store->getVar(SYSTEM_ENTER_AS_SUBMIT, STORE_SYSTEM));
Support::setIfNotSet($formSpec, F_SESSION_TIMEOUT_SECONDS, $this->store->getVar(SYSTEM_SESSION_TIMEOUT_SECONDS, STORE_SYSTEM));
......@@ -1453,10 +1452,18 @@ class QuickFormQuery {
// }
// }
//
$formSpec[F_MODE] = Support::getFormModeGlobal($formSpec[F_MODE]);
// Check for deprecated legacy code
if (isset($formSpec['mode'])) {
throw new \UserFormException(json_encode([ERROR_MESSAGE_TO_USER => 'Outdated form definition',
ERROR_MESSAGE_TO_DEVELOPER => "form.parameter.mode is deprecated. Please use form.parameter.formModeGlobal instead."
]));
}
// Unify F_MODE_GLOBAL
$formSpec[F_MODE_GLOBAL] = Support::getFormModeGlobal($formSpec[F_MODE_GLOBAL] ?? '');
if ($formSpec[F_MODE] == F_MODE_READONLY) {
if ($formSpec[F_MODE_GLOBAL] == F_MODE_READONLY) {
$formSpec[F_SHOW_BUTTON] = FORM_BUTTON_CLOSE;
$formSpec[F_SUBMIT_BUTTON_TEXT] = '';
}
......
......@@ -235,7 +235,7 @@ class FillStoreForm {
$clientFieldName = ($formMode == FORM_REST) ? $formElement[FE_NAME] : HelperFormElement::buildFormElementName($formElement, $fakeRecordId);
// Some Defaults
$formElement = Support::setFeDefaults($formElement, [F_MODE => $formModeGlobal]);
$formElement = Support::setFeDefaults($formElement, [FE_MODE => $formModeGlobal]);
if ($formElement[FE_TYPE] === FE_TYPE_EXTRA) {
// Extra elements will be transferred by SIP
......
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