Commit 0d45a374 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Hidden Values wurden nicht gespeichert. fixed.

Store.php: typo.
AbstractBuildForm.phhp: for all real form elements a fith't has been added: 'mode'.
parent 762ea337
...@@ -132,7 +132,7 @@ abstract class AbstractBuildForm { ...@@ -132,7 +132,7 @@ abstract class AbstractBuildForm {
/** /**
* Builds complete form. Depending of form specification, the layout will be 'plain' / 'table' / 'bootstrap'. * Builds complete form. Depending of form specification, the layout will be 'plain' / 'table' / 'bootstrap'.
* *
* @param $mode * @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
* @return string|array $mode=LOAD_FORM: The whole form as HTML, $mode=FORM_UPDATE: array of all formElement.dynamicUpdate-yes values/states * @return string|array $mode=LOAD_FORM: The whole form as HTML, $mode=FORM_UPDATE: array of all formElement.dynamicUpdate-yes values/states
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
...@@ -173,12 +173,10 @@ abstract class AbstractBuildForm { ...@@ -173,12 +173,10 @@ abstract class AbstractBuildForm {
} }
} else { } else {
$recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP); $recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP);
$htmlElements = $this->elements($recordId, $filter, 0, $json, $modeCollectFe, $htmlElementNameIdZero, $storeUse); $htmlElements = $this->elements($recordId, $filter, 0, $json, $modeCollectFe, $htmlElementNameIdZero, $storeUse, $mode);
} }
$htmlSip = $this->buildHiddenSip($json); $htmlSip = $this->buildHiddenSip($json);
// </form>
return ($mode === FORM_LOAD) ? $htmlHead . $htmlElements . $htmlSip . $htmlTail . $htmlSubrecords : $json; return ($mode === FORM_LOAD) ? $htmlHead . $htmlElements . $htmlSip . $htmlTail . $htmlSubrecords : $json;
} }
...@@ -328,13 +326,14 @@ abstract class AbstractBuildForm { ...@@ -328,13 +326,14 @@ abstract class AbstractBuildForm {
* @param string $modeCollectFe * @param string $modeCollectFe
* @param bool $htmlElementNameIdZero * @param bool $htmlElementNameIdZero
* @param string $storeUse * @param string $storeUse
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
* @throws \qfq\UserFormException * @throws \qfq\UserFormException
*/ */
public function elements($recordId, $filter = FORM_ELEMENTS_NATIVE, $feIdContainer = 0, array &$json, public function elements($recordId, $filter = FORM_ELEMENTS_NATIVE, $feIdContainer = 0, array &$json,
$modeCollectFe = FLAG_DYNAMIC_UPDATE, $htmlElementNameIdZero = false, $storeUse = STORE_USE_DEFAULT) { $modeCollectFe = FLAG_DYNAMIC_UPDATE, $htmlElementNameIdZero = false, $storeUse = STORE_USE_DEFAULT, $mode = FORM_LOAD) {
$html = ''; $html = '';
// get current data record // get current data record
...@@ -384,7 +383,7 @@ abstract class AbstractBuildForm { ...@@ -384,7 +383,7 @@ abstract class AbstractBuildForm {
$jsonElement = array(); $jsonElement = array();
// Render pure element // Render pure element
$elementHtml = $this->$buildElementFunctionName($formElement, $htmlFormElementId, $value, $jsonElement); $elementHtml = $this->$buildElementFunctionName($formElement, $htmlFormElementId, $value, $jsonElement, $mode);
// $fake0 = $fe['dynamicUpdate']; // $fake0 = $fe['dynamicUpdate'];
// $fake1 = $formElement['dynamicUpdate']; // $fake1 = $formElement['dynamicUpdate'];
...@@ -436,7 +435,10 @@ abstract class AbstractBuildForm { ...@@ -436,7 +435,10 @@ abstract class AbstractBuildForm {
* @throws \qfq\UserFormException * @throws \qfq\UserFormException
*/ */
public function buildHiddenSip(array &$json) { public function buildHiddenSip(array &$json) {
$sipArray = $this->store->getStore(STORE_SIP); $sipArray = $this->store->getStore(STORE_SIP);
// do not include system vars
unset($sipArray[SIP_SIP]); unset($sipArray[SIP_SIP]);
unset($sipArray[SIP_URLPARAM]); unset($sipArray[SIP_URLPARAM]);
...@@ -583,10 +585,11 @@ abstract class AbstractBuildForm { ...@@ -583,10 +585,11 @@ abstract class AbstractBuildForm {
* @param $htmlFormElementId * @param $htmlFormElementId
* @param $value * @param $value
* @param array $json * @param array $json
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
* @return string * @return string
* @throws \qfq\UserFormException * @throws \qfq\UserFormException
*/ */
public function buildInput(array $formElement, $htmlFormElementId, $value, array &$json) { public function buildInput(array $formElement, $htmlFormElementId, $value, array &$json, $mode = FORM_LOAD) {
$textarea = ''; $textarea = '';
$attribute = Support::doAttribute('name', $htmlFormElementId); $attribute = Support::doAttribute('name', $htmlFormElementId);
...@@ -852,11 +855,12 @@ abstract class AbstractBuildForm { ...@@ -852,11 +855,12 @@ abstract class AbstractBuildForm {
* @param $htmlFormElementId * @param $htmlFormElementId
* @param $value * @param $value
* @param array $json * @param array $json
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE*
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws \qfq\UserFormException * @throws \qfq\UserFormException
*/ */
public function buildCheckbox(array $formElement, $htmlFormElementId, $value, array &$json) { public function buildCheckbox(array $formElement, $htmlFormElementId, $value, array &$json, $mode = FORM_LOAD) {
$itemKey = array(); $itemKey = array();
$itemValue = array(); $itemValue = array();
...@@ -1185,13 +1189,19 @@ abstract class AbstractBuildForm { ...@@ -1185,13 +1189,19 @@ abstract class AbstractBuildForm {
* @param $htmlFormElementId * @param $htmlFormElementId
* @param $value * @param $value
* @param array $json * @param array $json
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws \qfq\UserFormException * @throws \qfq\UserFormException
*/ */
public function buildHidden(array $formElement, $htmlFormElementId, $value, array &$json) { public function buildHidden(array $formElement, $htmlFormElementId, $value, array &$json, $mode = FORM_LOAD) {
$this->store->setVar($htmlFormElementId, $value, STORE_SIP, false); if ($mode === FORM_LOAD) {
// Split 'grId:0' in 'grId' and '0'
$name = explode(':', $htmlFormElementId, 2);
$this->store->setVar($name[0], $value, STORE_SIP, false);
}
} }
/** /**
...@@ -1207,11 +1217,12 @@ abstract class AbstractBuildForm { ...@@ -1207,11 +1217,12 @@ abstract class AbstractBuildForm {
* @param $htmlFormElementId * @param $htmlFormElementId
* @param $value * @param $value
* @param array $json * @param array $json
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws \qfq\UserFormException * @throws \qfq\UserFormException
*/ */
public function buildRadio(array $formElement, $htmlFormElementId, $value, array &$json) { public function buildRadio(array $formElement, $htmlFormElementId, $value, array &$json, $mode = FORM_LOAD) {
$itemKey = array(); $itemKey = array();
$itemValue = array(); $itemValue = array();
...@@ -1284,11 +1295,12 @@ abstract class AbstractBuildForm { ...@@ -1284,11 +1295,12 @@ abstract class AbstractBuildForm {
* @param $htmlFormElementId * @param $htmlFormElementId
* @param $value * @param $value
* @param array $json * @param array $json
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
* @return mixed * @return mixed
* @throws CodeException * @throws CodeException
* @throws \qfq\UserFormException * @throws \qfq\UserFormException
*/ */
public function buildSelect(array $formElement, $htmlFormElementId, $value, array &$json) { public function buildSelect(array $formElement, $htmlFormElementId, $value, array &$json, $mode = FORM_LOAD) {
$itemKey = array(); $itemKey = array();
$itemValue = array(); $itemValue = array();
...@@ -1342,11 +1354,12 @@ abstract class AbstractBuildForm { ...@@ -1342,11 +1354,12 @@ abstract class AbstractBuildForm {
* @param $htmlFormElementId * @param $htmlFormElementId
* @param $value * @param $value
* @param array $json * @param array $json
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws \qfq\UserFormException * @throws \qfq\UserFormException
*/ */
public function buildSubrecord(array $formElement, $htmlFormElementId, $value, array &$json) { public function buildSubrecord(array $formElement, $htmlFormElementId, $value, array &$json, $mode = FORM_LOAD) {
$rcText = false; $rcText = false;
$nameColumnId = 'id'; $nameColumnId = 'id';
$targetTableName = ''; $targetTableName = '';
...@@ -1686,11 +1699,12 @@ abstract class AbstractBuildForm { ...@@ -1686,11 +1699,12 @@ abstract class AbstractBuildForm {
* @param $htmlFormElementId * @param $htmlFormElementId
* @param $value * @param $value
* @param array $json * @param array $json
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws \qfq\UserFormException * @throws \qfq\UserFormException
*/ */
public function buildFile(array $formElement, $htmlFormElementId, $value, array &$json) { public function buildFile(array $formElement, $htmlFormElementId, $value, array &$json, $mode = FORM_LOAD) {
$attribute = ''; $attribute = '';
# Build param array for uniq SIP # Build param array for uniq SIP
...@@ -1749,10 +1763,11 @@ abstract class AbstractBuildForm { ...@@ -1749,10 +1763,11 @@ abstract class AbstractBuildForm {
* @param $htmlFormElementId * @param $htmlFormElementId
* @param $value * @param $value
* @param array $json * @param array $json
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
* @return string * @return string
* @throws UserFormException * @throws UserFormException
*/ */
public function buildDateTime(array $formElement, $htmlFormElementId, $value, array &$json) { public function buildDateTime(array $formElement, $htmlFormElementId, $value, array &$json, $mode = FORM_LOAD) {
$attribute = Support::doAttribute('name', $htmlFormElementId); $attribute = Support::doAttribute('name', $htmlFormElementId);
$attribute .= Support::doAttribute('class', 'form-control'); $attribute .= Support::doAttribute('class', 'form-control');
...@@ -1849,10 +1864,11 @@ abstract class AbstractBuildForm { ...@@ -1849,10 +1864,11 @@ abstract class AbstractBuildForm {
* @param $htmlFormElementId * @param $htmlFormElementId
* @param $value * @param $value
* @param array $json * @param array $json
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
* @return string * @return string
* @throws UserFormException * @throws UserFormException
*/ */
public function buildDateJQW(array $formElement, $htmlFormElementId, $value, array &$json) { public function buildDateJQW(array $formElement, $htmlFormElementId, $value, array &$json, $mode = FORM_LOAD) {
$arrMinMax = null; $arrMinMax = null;
// if ($formElement['placeholder'] == '') { // if ($formElement['placeholder'] == '') {
...@@ -1929,9 +1945,11 @@ abstract class AbstractBuildForm { ...@@ -1929,9 +1945,11 @@ abstract class AbstractBuildForm {
* @param array $formElement * @param array $formElement
* @param $htmlFormElementId * @param $htmlFormElementId
* @param $value * @param $value
* @param $fake
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
* @throws UserFormException * @throws UserFormException
*/ */
public function buildGridJQW(array $formElement, $htmlFormElementId, $value) { public function buildGridJQW(array $formElement, $htmlFormElementId, $value, $fake, $mode = FORM_LOAD) {
// TODO: implement // TODO: implement
throw new UserFormException("Not implemented yet: buildGridJQW()", ERROR_NOT_IMPLEMENTED); throw new UserFormException("Not implemented yet: buildGridJQW()", ERROR_NOT_IMPLEMENTED);
} }
...@@ -1942,10 +1960,11 @@ abstract class AbstractBuildForm { ...@@ -1942,10 +1960,11 @@ abstract class AbstractBuildForm {
* @param array $formElement * @param array $formElement
* @param $htmlFormElementId * @param $htmlFormElementId
* @param $value * @param $value
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
* @param array $json * @param array $json
* @return mixed * @return mixed
*/ */
public function buildNote(array $formElement, $htmlFormElementId, $value, array &$json) { public function buildNote(array $formElement, $htmlFormElementId, $value, array &$json, $mode = FORM_LOAD) {
return $value; return $value;
} }
...@@ -1969,11 +1988,12 @@ abstract class AbstractBuildForm { ...@@ -1969,11 +1988,12 @@ abstract class AbstractBuildForm {
* @param $htmlFormElementId * @param $htmlFormElementId
* @param $value * @param $value
* @param array $json * @param array $json
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
* @return mixed * @return mixed
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
*/ */
public function buildFieldset(array $formElement, $htmlFormElementId, $value, array &$json) { public function buildFieldset(array $formElement, $htmlFormElementId, $value, array &$json, $mode = FORM_LOAD) {
$attribute = ''; $attribute = '';
// save parent processed FE's // save parent processed FE's
......
...@@ -294,10 +294,12 @@ class Save { ...@@ -294,10 +294,12 @@ class Save {
* @return bool|array if found the FormElement, else false. * @return bool|array if found the FormElement, else false.
*/ */
private function getFormElementByName($name) { private function getFormElementByName($name) {
foreach ($this->feSpecNative as $formElement) { foreach ($this->feSpecNative as $formElement) {
if ($formElement['name'] === $name) if ($formElement['name'] === $name)
return $formElement; return $formElement;
} }
return false; return false;
} }
......
...@@ -456,7 +456,7 @@ class Store { ...@@ -456,7 +456,7 @@ class Store {
throw new CodeException("setVar() for STORE_ZERO is impossible - there are no values.", ERROR_SET_STORE_ZERO); throw new CodeException("setVar() for STORE_ZERO is impossible - there are no values.", ERROR_SET_STORE_ZERO);
if ($overWrite === false && isset(self::$raw[$store][$key])) { if ($overWrite === false && isset(self::$raw[$store][$key])) {
throw new UserFormException("Value of '$key' already be set in store '$store'.", ERROR_STORE_KEY_EXIST); throw new UserFormException("Value of '$key' already set in store '$store'.", ERROR_STORE_KEY_EXIST);
} }
self::$raw[$store][$key] = $value; self::$raw[$store][$key] = $value;
......
...@@ -99,14 +99,14 @@ VALUES ...@@ -99,14 +99,14 @@ VALUES
# #
DROP TABLE IF EXISTS Address; DROP TABLE IF EXISTS Address;
CREATE TABLE Address ( CREATE TABLE Address (
id BIGINT AUTO_INCREMENT PRIMARY KEY, id BIGINT AUTO_INCREMENT PRIMARY KEY,
personId BIGINT NOT NULL DEFAULT 0, personId BIGINT NOT NULL DEFAULT 0,
street VARCHAR(128) NOT NULL DEFAULT '', street VARCHAR(128) NOT NULL DEFAULT '',
city VARCHAR(128) NOT NULL DEFAULT '', city VARCHAR(128) NOT NULL DEFAULT '',
country ENUM('Switzerland', 'Austria', 'France', 'Germany') NOT NULL, country ENUM('Switzerland', 'Austria', 'France', 'Germany') NOT NULL,
gr_id_typ BIGINT NOT NULL DEFAULT 0, grIdTyp BIGINT NOT NULL DEFAULT 0,
modified TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, modified TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'
); );
......
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