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
Pipeline #3127 passed with stages
in 2 minutes
...@@ -243,6 +243,7 @@ class Save { ...@@ -243,6 +243,7 @@ class Save {
private function elements($recordId) { private function elements($recordId) {
$columnCreated = false; $columnCreated = false;
$columnModified = false; $columnModified = false;
$realColumnFound = false;
$newValues = array(); $newValues = array();
...@@ -260,6 +261,7 @@ class Save { ...@@ -260,6 +261,7 @@ class Save {
// Skip Upload Elements: those will be processed later. // Skip Upload Elements: those will be processed later.
if ($this->isColumnUploadField($column)) { if ($this->isColumnUploadField($column)) {
$realColumnFound = true;
continue; continue;
} }
...@@ -285,10 +287,14 @@ class Save { ...@@ -285,10 +287,14 @@ class Save {
Support::setIfNotSet($formValues, $column); Support::setIfNotSet($formValues, $column);
} }
$newValues[$column] = $formValues[$column]; $newValues[$column] = $formValues[$column];
$realColumnFound = true;
} }
if ($columnModified && !empty($newValues) && !isset($newValues[COLUMN_MODIFIED])) { // Only save record if real columns exist.
if ($realColumnFound) {
if ($columnModified && !isset($newValues[COLUMN_MODIFIED])) {
$newValues[COLUMN_MODIFIED] = date('YmdHis'); $newValues[COLUMN_MODIFIED] = date('YmdHis');
} }
...@@ -296,18 +302,16 @@ class Save { ...@@ -296,18 +302,16 @@ class Save {
if ($columnCreated && !isset($newValues[COLUMN_CREATED])) { if ($columnCreated && !isset($newValues[COLUMN_CREATED])) {
$newValues[COLUMN_CREATED] = date('YmdHis'); $newValues[COLUMN_CREATED] = date('YmdHis');
} }
$rc = $this->insertRecord($this->formSpec[F_TABLE_NAME], $newValues); $recordId = $this->insertRecord($this->formSpec[F_TABLE_NAME], $newValues);
} else { } else {
if (!empty($newValues)) {
$this->updateRecord($this->formSpec[F_TABLE_NAME], $newValues, $recordId, $this->formSpec[F_PRIMARY_KEY]); $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;
} }
/** /**
......
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