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

templateGroup: fixed problem with missing <div class='qfq-line'> around each...

templateGroup: fixed problem with missing <div class='qfq-line'> around each copy of prefilled templateGroup.
 AbstractBuildForm.php: pattern  '%d' will be replaced by number of copy in FormElement 'label' and 'note'. Recode Logic to wrap templateGroup copies.
parent b6b93b6f
......@@ -2339,15 +2339,16 @@ abstract class AbstractBuildForm {
$default = $this->store->getStore(STORE_TABLE_DEFAULT); // current defaults
$lastFilled = 0; // Marker if there is at least one element per copy who is filled.
$feSpecNativeFilled = array();
$feSpecNativeCopy = array();
for($ii = 1; $ii < $max; $ii++) {
$feSpecNativeNew = array();
// Per copy, iterate over all templateGroup FormElements
foreach($this->feSpecNative as $fe) {
$columnName = str_replace(FE_TEMPLATE_GROUP_NAME_PATTERN, $ii, $fe[FE_NAME]);
$fe[FE_LABEL] = str_replace(FE_TEMPLATE_GROUP_NAME_PATTERN, $ii, $fe[FE_LABEL]);
$fe[FE_NOTE] = str_replace(FE_TEMPLATE_GROUP_NAME_PATTERN, $ii, $fe[FE_NOTE]);
if(isset($record[$columnName])) {
if($record[$columnName] != $default[$columnName]) {
$lastFilled = $ii;
......@@ -2356,31 +2357,33 @@ abstract class AbstractBuildForm {
throw new UserFormException("Not implemented: templateGroup FormElement-columns not found in primary table.", ERROR_NOT_IMPLEMENTED);
}
$fe[FE_NAME] = $columnName;
$feSpecNativeNew[] = $fe; // Build array with current copy of templateGroup.
$feSpecNativeCopy[$ii-1][] = $fe; // Build array with current copy of templateGroup.
}
// Append $htmlDelete on the last element of all copies but the first.
// Append $htmlDelete on the last element of all copies,, but not the first.
if($ii>1) {
// Count defined FormElements in the current templateGroup
$last = count($feSpecNativeNew) - 1;
$last = count($feSpecNativeCopy[$ii-1]) - 1;
// Append 'delete' Button at the note of the last element
$feSpecNativeNew[$last][FE_NOTE] .= $htmlDelete;
$feSpecNativeCopy[$ii-1][$last][FE_NOTE] .= $htmlDelete;
}
$feSpecNativeFilled = array_merge($feSpecNativeFilled, $feSpecNativeNew);
}
// Nothing found: return
if(count($feSpecNativeFilled)==0){
if(count($feSpecNativeCopy)==0){
return '';
}
// Take all copies upto the last filled element.
$feSpecNativeFilled = array_slice($feSpecNativeFilled,0, $lastFilled * count($this->feSpecNative));
$feSpecNativeSave = $this->feSpecNative;
$this->feSpecNative = $feSpecNativeFilled;
$html = $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_NATIVE, 0, $json);
$html = '';
for($ii=0; $ii<$lastFilled; $ii++) {
$this->feSpecNative = $feSpecNativeCopy[$ii];
$htmlCopy = $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_NATIVE, 0, $json);
$htmlCopy = Support::wrapTag('<div class="qfq-line">', $htmlCopy);
$html .= $htmlCopy;
}
$this->feSpecNative = $feSpecNativeSave;
return $html;
......@@ -2445,13 +2448,11 @@ EOT;
['yes', $this->formSpec["id"], 'native,container', $formElement['id']], $this->formSpec);
// Count defined FormElements in the current templateGroup
$last = count($this->feSpecNative) - 1;
if ($last < 0) {
$elementsTotal = count($this->feSpecNative);
if ($elementsTotal < 1) {
$this->feSpecNative = $feSpecNativeSave;
return '';
}
// Append 'delete' Button at the note of the last element
$this->feSpecNative[$last][FE_NOTE] .= $htmlDelete;
// If there are already elements filled, take them.
$html = $this->templateGroupCollectFilledElements($max, $htmlDelete, $json);
......@@ -2472,6 +2473,9 @@ EOT;
$html = $this->wrap[WRAP_SETUP_IN_TEMPLATE_GROUP][WRAP_SETUP_START] . $html . $this->wrap[WRAP_SETUP_IN_TEMPLATE_GROUP][WRAP_SETUP_END];
// Append 'delete' Button after 'note' of the templateGroups last element.
$this->feSpecNative[$elementsTotal - 1][FE_NOTE] .= $htmlDelete;
// Get FE natives
$template = $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_NATIVE, 0, $json);
......
......@@ -59,7 +59,6 @@ const SANITIZE_ALLOW_MIN_MAX = "min|max";
const SANITIZE_ALLOW_MIN_MAX_DATE = "min|max date";
const SANITIZE_ALLOW_PATTERN = "pattern";
const SANITIZE_ALLOW_ALLBUT = "allbut";
const SANITIZE_ALLOW_ALLBUT = "allbut";
const SANITIZE_ALLOW_ALL = "all";
const SANITIZE_DEFAULT = SANITIZE_ALLOW_DIGIT;
......
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