Commit 1c95ff76 authored by Carsten  Rose's avatar Carsten Rose
Browse files

#3853 / New > Save: Reload des Forms mit neuer SIP und neu erstellter recordId.

Partly remove unused code 'htmlNameIdZero'. Instead implement generation of a new SIP for the new record and reload the current page with the new SIP.
QuickFormQuery.php: remove newRecordUpdateSip(). Set URL redirection if none specific is configured. Skip creation of json code if page will be reloaded.
parent b21436e5
......@@ -159,14 +159,14 @@ class QuickFormQuery {
}
/**
* Returns the defined forwardMode and set $forwardPage (call be reference)
* Returns the defined forwardMode and set $forwardPage (call by reference)
*
* @param $forwardPage
* @return mixed
*/
public function getForwardMode(&$forwardPage) {
$forwardPage = $this->formSpec['forwardPage'];
return $this->formSpec['forwardMode'];
$forwardPage = $this->formSpec[F_FORWARD_PAGE];
return $this->formSpec[F_FORWARD_MODE];
}
/**
......@@ -221,7 +221,7 @@ class QuickFormQuery {
$fillStoreForm->process();
}
$recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_TYPO3 . STORE_CLIENT);
$recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_TYPO3 . STORE_CLIENT . STORE_ZERO);
$formName = $this->loadFormSpecification($formMode, $recordId, $foundInStore);
if ($formName === false && $formMode !== FORM_DELETE) {
......@@ -246,7 +246,7 @@ class QuickFormQuery {
// For 'new' record always create a new Browser TAB-uniq (for this current form, nowhere else used) SIP.
// With such a Browser TAB-uniq SIP, multiple Browser TABs and following repeated NEWs are easily implemented.
if (!$sipFound || ($formMode == FORM_LOAD && $recordId == 0)) {
if (!$sipFound || ($formMode == FORM_LOAD && $recordId === 0)) {
$this->store->createSipAfterFormLoad($formName);
}
......@@ -328,21 +328,42 @@ class QuickFormQuery {
$this->fillStoreWithRecord($this->formSpec[F_TABLE_NAME], $rc, STORE_RECORD);
}
$htmlElementNameIdZero = false;
// $htmlElementNameIdZero = false;
$getJson = true;
// Retrieve current STORE_SIP.
$sipArray = $this->store->getStore(STORE_SIP);
if ($sipArray[SIP_RECORD_ID] == 0) {
// After insert: a new SIP for the new record id is required.
$this->newRecordUpdateSip($rc);
$htmlElementNameIdZero = true;
// For 'new' do a full reload of the form with a new SIP.
if ($this->formSpec[F_FORWARD_MODE] !== F_FORWARD_MODE_PAGE) {
$this->formSpec[F_FORWARD_MODE] = F_FORWARD_MODE_PAGE;
// Rebuild original URL
$storeT3 = $this->store->getStore(STORE_TYPO3);
$storeT3['id'] = $storeT3[TYPO3_PAGE_ID];
$storeT3 = OnArray::getArrayItems($storeT3, ['id', TYPO3_PAGE_TYPE, TYPO3_PAGE_LANGUAGE], true, true);
$arr = KeyValueStringParser::parse($this->store->getVar(SIP_URLPARAM, STORE_SIP), '=', '&');
$arr[SIP_RECORD_ID] = $rc;
$arr = array_merge($storeT3, $arr);
$queryString = KeyValueStringParser::unparse($arr, '=', '&');
$this->formSpec[F_FORWARD_PAGE] = store::getSipInstance()->queryStringToSip($queryString, RETURN_URL);
}
$getJson = false;
}
// Action: Sendmail
$formAction->elements($rc, $this->feSpecAction, FE_TYPE_SENDMAIL);
// Retrieve FE Values as JSON
// $data['form-update']=...
$data = $build->process($formMode, $htmlElementNameIdZero);
if ($getJson) {
// Retrieve FE Values as JSON
// $data['form-update']=...
// $data = $build->process($formMode, $htmlElementNameIdZero);
$data = $build->process($formMode);
}
break;
default:
......@@ -773,29 +794,6 @@ class QuickFormQuery {
}
}
/**
* Update current SIP Store with new $recordId and update SESSION store.
*
* @param $recordId
* @throws CodeException
* @throws UserFormException
*/
private function newRecordUpdateSip($recordId) {
// Update current SIP store with new RecordID
$sipArray = $this->store->getStore(STORE_SIP);
if (isset($sipArray[SIP_RECORD_ID]) && $sipArray[SIP_RECORD_ID] > 0) {
throw new CodeException('Attemp to overwrite existing record id: SIP(otf)=' . $sipArray[SIP_SIP] . " existing_r=" . $sipArray[SIP_RECORD_ID] . " new_r=" . $recordId, ERROR_OVERWRITE_RECORD_ID);
}
$sipArray[SIP_RECORD_ID] = $recordId;
$this->store->setStore($sipArray, STORE_SIP, true);
// Update SIP urlparam
store::getSipInstance()->updateSipToSession($sipArray);
}
/**
* Searches the whole array $dataArray on the second level for API_ELEMENT_UPDATE.
* All found elements collect under $collect[API_ELEMENT_UPDATE]... . Leave the rest unchanged.
......
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