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

save: Fixed not to save SIP values without corresponding FormElement or values...

save: Fixed not to save SIP values without corresponding FormElement or values from FormElements which are hidden or readonly.
Save.php: removed code to get FormElement - no benefit of this information.
parent 4597470e
...@@ -433,3 +433,4 @@ const DB_NUM_ROWS = 'numRows'; ...@@ -433,3 +433,4 @@ const DB_NUM_ROWS = 'numRows';
const DB_AFFECTED_ROWS = 'affectedRows'; const DB_AFFECTED_ROWS = 'affectedRows';
const DB_INSERT_ID = 'insertId'; const DB_INSERT_ID = 'insertId';
const COLUMN_CREATED = 'created';
\ No newline at end of file
...@@ -89,26 +89,16 @@ class Save { ...@@ -89,26 +89,16 @@ class Save {
foreach ($tableColumns AS $column) { foreach ($tableColumns AS $column) {
// Never save a predefined 'id': autoincrement values will be given by database.. // Never save a predefined 'id': autoincrement values will be given by database..
if ($column === 'id') if ($column === 'id') {
continue; continue;
}
// Get related formElement. // Is there a value? Do not forget SIP values. Those do not have necessarily a FormElement.
$formElement = $this->getFormElementByName($column); if (!isset($formValues[$column])) {
if ($formElement === false)
continue; continue;
// Some modes means: do not save this column.
switch ($formElement[FE_MODE]) {
case FE_MODE_READONLY:
case FE_MODE_HIDDEN:
continue 2; // 1 for switch, 2 for continue foreach.
default:
break;
} }
$this->store->setVar(SYSTEM_FORM_ELEMENT, "Column: $column", STORE_SYSTEM);
// Preparation for Log, Debug
$this->store->setVar(SYSTEM_FORM_ELEMENT, Logger::formatFormElementName($formElement), STORE_SYSTEM);
Support::setIfNotSet($formValues, $column); Support::setIfNotSet($formValues, $column);
$newValues[$column] = $formValues[$column]; $newValues[$column] = $formValues[$column];
...@@ -232,19 +222,6 @@ class Save { ...@@ -232,19 +222,6 @@ class Save {
return $pathFileName; return $pathFileName;
} }
/**
* Get the complete FormElement for $name
*
* @param $name
* @return bool|array if found the FormElement, else false.
*/
private function getFormElementByName($name) {
foreach ($this->feSpecNative as $formElement) {
if ($formElement['name'] === $name)
return $formElement;
}
return false;
}
/** /**
* Insert new record in table $this->formSpec['tableName']. * Insert new record in table $this->formSpec['tableName'].
...@@ -303,4 +280,18 @@ class Save { ...@@ -303,4 +280,18 @@ class Save {
return $rc; return $rc;
} }
/**
* Get the complete FormElement for $name
*
* @param $name
* @return bool|array if found the FormElement, else false.
*/
private function getFormElementByName($name) {
foreach ($this->feSpecNative as $formElement) {
if ($formElement['name'] === $name)
return $formElement;
}
return false;
}
} }
\ No newline at end of file
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