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

Bug #4548 /Template Group: 'form-update' broken

* Broken Redirect after Save - fixed
* Broken same HTML ID for FE copies in a template group. - fixed
parent c2faa36a
......@@ -166,6 +166,7 @@ abstract class AbstractBuildForm {
$htmlElements = '';
$json = array();
// After action 'afterSave', it's necessary to reinitialize the FeSpecNative
if (!empty($latestFeSpecNative)) {
$this->feSpecNative = $latestFeSpecNative;
}
......
......@@ -394,7 +394,6 @@ class QuickFormQuery {
// Action: Sendmail
$formAction->elements($rc, $this->feSpecAction, FE_TYPE_SENDMAIL);
$getJson = true;
$customForward = $this->setForwardModePage();
......@@ -402,6 +401,7 @@ class QuickFormQuery {
// b) User presses only 'save' (not save & close) and
// c) there is no forwardMode=='url...'
// then the client should reload the current page with the newly created record. A new SIP is necessary!
$getJson = true;
if (0 == $this->store->getVar(SIP_RECORD_ID, STORE_SIP) &&
API_SUBMIT_REASON_SAVE == $this->store->getVar(API_SUBMIT_REASON, STORE_CLIENT . STORE_EMPTY, SANITIZE_ALLOW_ALNUMX) &&
$customForward == false
......@@ -412,14 +412,16 @@ class QuickFormQuery {
if ($getJson) {
// Values of FormElements might be changed during 'afterSave': rebuild the form to load the new values. Especially for advanced template groups.
$this->loadFormSpecification($formMode, $recordId, $foundInStore);
// Values of FormElements might be changed during 'afterSave': rebuild the form to load the new values. Especially for non primary template groups.
// $this->loadFormSpecification($formMode, $recordId, $foundInStore);
$this->feSpecNative = $this->getNativeFormElements(SQL_FORM_ELEMENT_NATIVE_TG_COUNT, [$this->formSpec["id"]], $this->formSpec);
// Retrieve FE Values as JSON
// $data['form-update']=...
// $data = $build->process($formMode, $htmlElementNameIdZero);
$data = $build->process($formMode, false, $this->feSpecNative);
}
break;
default:
......@@ -664,7 +666,6 @@ class QuickFormQuery {
case FORM_SAVE:
case FORM_UPDATE:
// $this->feSpecNative = $this->db->getNativeFormElements(SQL_FORM_ELEMENT_ALL_CONTAINER, ['no', $this->formSpec["id"], 'native'], $this->formSpec);
$feSpecNative = $this->getNativeFormElements(SQL_FORM_ELEMENT_NATIVE_TG_COUNT, [$this->formSpec["id"]], $this->formSpec);
break;
......@@ -750,6 +751,7 @@ class QuickFormQuery {
unset($tmpRow[NAME_TG_COPIES]);
$tmpRow[FE_NAME] = str_replace(FE_TEMPLATE_GROUP_NAME_PATTERN, $ii, $tmpRow[FE_NAME]);
$tmpRow[FE_LABEL] = str_replace(FE_TEMPLATE_GROUP_NAME_PATTERN, $ii, $tmpRow[FE_LABEL]);
$tmpRow[FE_TG_INDEX] = $ii;
$new[] = $tmpRow;
}
} else {
......
......@@ -175,6 +175,8 @@ class HelperFormElement {
unset($fe[FE_RETYPE_NOTE]);
}
$fe[FE_TG_INDEX] = 1; // Not sure if this is helpfull in case of dynamic update - but it will make the element uniqe.
unset($fe[FE_RETYPE]);
$arr[] = $fe;
}
......
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