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

Merge branch 'B8587NoSaveOnFormMissingRealColumn' into 'master'

Fixes #8587. A form triggers a save only, if there are real table columns.

See merge request !240
parents ee331df4 4130273d
No related branches found
No related tags found
1 merge request!240Fixes #8587. A form triggers a save only, if there are real table columns.
Pipeline #3127 passed
......@@ -234,7 +234,7 @@ class Save {
*
* @param $recordId
*
* @return int record id (in case of insert, it's different from $recordId)
* @return int record id (in case of insert, it's different from $recordId)
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
......@@ -243,6 +243,7 @@ class Save {
private function elements($recordId) {
$columnCreated = false;
$columnModified = false;
$realColumnFound = false;
$newValues = array();
......@@ -260,6 +261,7 @@ class Save {
// Skip Upload Elements: those will be processed later.
if ($this->isColumnUploadField($column)) {
$realColumnFound = true;
continue;
}
......@@ -285,29 +287,31 @@ class Save {
Support::setIfNotSet($formValues, $column);
}
$newValues[$column] = $formValues[$column];
$realColumnFound = true;
}
if ($columnModified && !empty($newValues) && !isset($newValues[COLUMN_MODIFIED])) {
$newValues[COLUMN_MODIFIED] = date('YmdHis');
}
// Only save record if real columns exist.
if ($realColumnFound) {
if ($recordId == 0) {
if ($columnCreated && !isset($newValues[COLUMN_CREATED])) {
$newValues[COLUMN_CREATED] = date('YmdHis');
if ($columnModified && !isset($newValues[COLUMN_MODIFIED])) {
$newValues[COLUMN_MODIFIED] = date('YmdHis');
}
$rc = $this->insertRecord($this->formSpec[F_TABLE_NAME], $newValues);
} else {
if (!empty($newValues)) {
if ($recordId == 0) {
if ($columnCreated && !isset($newValues[COLUMN_CREATED])) {
$newValues[COLUMN_CREATED] = date('YmdHis');
}
$recordId = $this->insertRecord($this->formSpec[F_TABLE_NAME], $newValues);
} else {
$this->updateRecord($this->formSpec[F_TABLE_NAME], $newValues, $recordId, $this->formSpec[F_PRIMARY_KEY]);
}
$rc = $recordId;
}
$this->nativeDoSlave($rc);
$this->nativeDoSlave($recordId);
return $rc;
return $recordId;
}
/**
......
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