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

Set modified & created on Form save.

During save of a record, if column 'modifed' and/or ' created' exist, set them.
parent 12fbff0a
No related branches found
No related tags found
No related merge requests found
......@@ -77,6 +77,8 @@ class Save {
* @throws UserFormException
*/
public function elements($recordId) {
$columnCreated = false;
$columnModified = false;
$newValues = array();
......@@ -93,6 +95,14 @@ class Save {
continue;
}
if ($column === COLUMN_CREATED) {
$columnCreated = true;
}
if ($column === COLUMN_MODIFIED) {
$columnModified = true;
}
// Is there a value? Do not forget SIP values. Those do not have necessarily a FormElement.
if (!isset($formValues[$column])) {
continue;
......@@ -104,7 +114,14 @@ class Save {
$newValues[$column] = $formValues[$column];
}
if ($columnModified && !isset($newValues[COLUMN_MODIFIED])) {
$newValues[COLUMN_MODIFIED] = date('YmdHis');
}
if ($recordId == 0) {
if ($columnCreated && !isset($newValues[COLUMN_CREATED])) {
$newValues[COLUMN_CREATED] = date('YmdHis');
}
$rc = $this->insertRecord($this->formSpec[F_TABLE_NAME], $newValues);
} else {
$this->updateRecord($this->formSpec[F_TABLE_NAME], $newValues, $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