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';
const DB_AFFECTED_ROWS = 'affectedRows';
const DB_INSERT_ID = 'insertId';
const COLUMN_CREATED = 'created';
\ No newline at end of file
......@@ -89,26 +89,16 @@ class Save {
foreach ($tableColumns AS $column) {
// Never save a predefined 'id': autoincrement values will be given by database..
if ($column === 'id')
if ($column === 'id') {
continue;
}
// Get related formElement.
$formElement = $this->getFormElementByName($column);
if ($formElement === false)
// Is there a value? Do not forget SIP values. Those do not have necessarily a FormElement.
if (!isset($formValues[$column])) {
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;
}
// Preparation for Log, Debug
$this->store->setVar(SYSTEM_FORM_ELEMENT, Logger::formatFormElementName($formElement), STORE_SYSTEM);
$this->store->setVar(SYSTEM_FORM_ELEMENT, "Column: $column", STORE_SYSTEM);
Support::setIfNotSet($formValues, $column);
$newValues[$column] = $formValues[$column];
......@@ -232,19 +222,6 @@ class Save {
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'].
......@@ -303,4 +280,18 @@ class Save {
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