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

DynamicUpdate for checkBoxMulti: not possible at the moment - a persistant...

DynamicUpdate for checkBoxMulti: not possible at the moment - a persistant store per browser tab is necessary. Some work already done.
FillStoreForm.php: clientValues will be copied to STORE_FORM if mode=show|requiered or flag 'dynamicUpdate' is set. Fixed bug with additional ',' in collectMultiValues().
parent 8ea0a6ee
......@@ -45,7 +45,7 @@ const RETURN_ARRAY = 'return_array';
const SQL_FORM_ELEMENT_SPECIFIC_CONTAINER = "SELECT *, ? AS 'nestedInFieldSet' FROM FormElement AS fe WHERE fe.formId = ? AND fe.deleted = 'no' AND FIND_IN_SET(fe.class, ? ) AND fe.feIdContainer = ? AND fe.enabled='yes' ORDER BY fe.ord, fe.id";
const SQL_FORM_ELEMENT_ALL_CONTAINER = "SELECT *, ? AS 'nestedInFieldSet' FROM FormElement AS fe WHERE fe.formId = ? AND fe.deleted = 'no' AND FIND_IN_SET(fe.class, ? ) AND fe.enabled='yes' ORDER BY fe.ord, fe.id";
const SQL_FORM_ELEMENT_SIMPLE_ALL_CONTAINER = "SELECT fe.id, fe.name, fe.label, fe.type, fe.checkType, fe.checkPattern, fe.mode, fe.modeSql, fe.parameter FROM FormElement AS fe, Form AS f WHERE f.name = ? AND f.id = fe.formId AND fe.deleted = 'no' AND fe.class = 'native' AND fe.enabled='yes' ORDER BY fe.ord, fe.id";
const SQL_FORM_ELEMENT_SIMPLE_ALL_CONTAINER = "SELECT fe.id, fe.name, fe.label, fe.type, fe.checkType, fe.checkPattern, fe.mode, fe.modeSql, fe.parameter, fe.dynamicUpdate FROM FormElement AS fe, Form AS f WHERE f.name = ? AND f.id = fe.formId AND fe.deleted = 'no' AND fe.class = 'native' AND fe.enabled='yes' ORDER BY fe.ord, fe.id";
// SANITIZE Classifier
const SANITIZE_ALLOW_ALNUMX = "alnumx";
......@@ -385,6 +385,8 @@ const FE_SUBRECORD_ROW_TITLE = '_rowTitle';
const FE_TYPE = 'type';
const FE_MODE = 'mode';
const FE_MODE_SQL = 'modeSql';
// TODO: Konstante FE_DYNAMIC_UPDATE ueberall einsetzen
const FE_DYNAMIC_UPDATE = 'dynamicUpdate';
// FormElement columns: via parameter field
const FE_DATE_FORMAT = 'dateFormat'; // value: FORMAT_DATE_INTERNATIONAL | FORMAT_DATE_GERMAN
......
......@@ -144,31 +144,22 @@ class FillStoreForm {
}
}
switch ($formElement[FE_MODE]) {
case FE_MODE_REQUIRED:
case FE_MODE_SHOW:
if (isset($clientValues[$clientFieldName])) {
switch ($formElement[FE_TYPE]) {
case 'date':
case 'datetime':
case 'time':
if ($clientValues[$clientFieldName] !== '') // do not check empty values
$newValues[$formElement['name']] = $this->doDateTime($formElement, $clientValues[$clientFieldName]);
break;
default:
$newValues[$formElement['name']] = Sanitize::sanitize($clientValues[$clientFieldName],
$formElement['checkType'], $formElement['checkPattern'], SANATIZE_EXCEPTION);
break;
}
// copy value to $newValues
if (isset($clientValues[$clientFieldName])) {
if ($formElement[FE_DYNAMIC_UPDATE] === 'yes' || $formElement[FE_MODE] === FE_MODE_REQUIRED || $formElement[FE_MODE] === FE_MODE_SHOW) {
switch ($formElement[FE_TYPE]) {
case 'date':
case 'datetime':
case 'time':
if ($clientValues[$clientFieldName] !== '') // do not check empty values
$newValues[$formElement['name']] = $this->doDateTime($formElement, $clientValues[$clientFieldName]);
break;
default:
$newValues[$formElement['name']] = Sanitize::sanitize($clientValues[$clientFieldName],
$formElement['checkType'], $formElement['checkPattern'], SANATIZE_EXCEPTION);
break;
}
break;
case FE_MODE_READONLY:
case FE_MODE_HIDDEN:
continue;
default:
throw new CodeException("Unknown mode: " . $formElement[FE_MODE], ERROR_UNKNOWN_MODE);
}
}
}
......@@ -186,9 +177,11 @@ class FillStoreForm {
private function collectMultiValues($clientFieldName, array $clientValues) {
$checkboxKey = HelperFormElement::prependFormElementIdCheckBoxMulti($clientFieldName, 'h');
// Check there is a hidden value with naming in checkbox multi syntax
if (isset($clientValues[$checkboxKey])) {
$checkboxValue = $clientValues[$checkboxKey];
$pattern = '/' . HelperFormElement::prependFormElementIdCheckBoxMulti($clientFieldName, '\d+') . '/';
foreach ($clientValues as $key => $value) {
if (1 === preg_match($pattern, $key)) {
......@@ -196,6 +189,10 @@ class FillStoreForm {
}
}
if (isset($checkboxValue[0]) && $checkboxValue[0] === ',') {
$checkboxValue = substr($checkboxValue, 1);
}
$clientValues[$clientFieldName] = $checkboxValue;
}
......
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