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

QuickFormQuery.php: for modeForm='Form Delete' the 'required param' are not...

QuickFormQuery.php: for modeForm='Form Delete' the 'required param' are not respected - this makes sense, cause these parameters typically filled in newly created records.
parent c3afadfe
......@@ -207,30 +207,30 @@ class QuickFormQuery {
* FORM_SAVE: The submitted form will be saved. Return Failure or Success as JSON.
* FORM_DELETE:
*
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE | FORM_DELETE
* @param string $formMode FORM_LOAD | FORM_UPDATE | FORM_SAVE | FORM_DELETE
* @return array|string
* @throws CodeException
* @throws UserFormException
*/
private function doForm($mode) {
private function doForm($formMode) {
$data = '';
$foundInStore = '';
// Fill STORE_FORM
if ($mode === FORM_UPDATE || $mode === FORM_SAVE) {
if ($formMode === FORM_UPDATE || $formMode === FORM_SAVE) {
$fillStoreForm = new FillStoreForm();
$fillStoreForm->process();
}
$formName = $this->loadFormSpecification($mode, $foundInStore);
if ($formName === false && $mode !== FORM_DELETE) {
$formName = $this->loadFormSpecification($formMode, $foundInStore);
if ($formName === false && $formMode !== FORM_DELETE) {
// No form found: do nothing
return '';
}
if ($formName !== false) {
// Validate only if there is a 'real' form (not a FORM_DELETE with only a tablename).
$sipFound = $this->validateForm($foundInStore);
$sipFound = $this->validateForm($foundInStore, $formMode);
} else {
// FORM_DELETE without a form definition: Fake the form wiht only a tableName.
......@@ -246,11 +246,11 @@ class QuickFormQuery {
$recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_TYPO3 . STORE_CLIENT);
// For 'new' record always create a new TAB-uniq (for this current form, nowhere else used) SIP.
// With such a TAB-uniq SIP, multiple TABs and following repeated NEWs are easily implemented.
if (!$sipFound || ($mode == FORM_LOAD && $recordId == 0)) {
if (!$sipFound || ($formMode == FORM_LOAD && $recordId == 0)) {
$this->store->createSipAfterFormLoad($formName);
}
if ($mode === FORM_DELETE) {
if ($formMode === FORM_DELETE) {
$build = new Delete();
......@@ -273,12 +273,12 @@ class QuickFormQuery {
}
$formAction = new FormAction($this->formSpec, $this->db, $this->phpUnit);
switch ($mode) {
switch ($formMode) {
case FORM_LOAD:
case FORM_UPDATE:
$formAction->elements($recordId, $this->feSpecAction, FE_TYPE_BEFORE_LOAD);
$data = $build->process($mode);
$data = $build->process($formMode);
$formAction->elements($recordId, $this->feSpecAction, FE_TYPE_AFTER_LOAD);
break;
......@@ -328,7 +328,7 @@ class QuickFormQuery {
$formAction->elements($rc, $this->feSpecAction, FE_TYPE_SENDMAIL);
// Retrieve FE Values as JSON
$data = $build->process($mode, $htmlElementNameIdZero);
$data = $build->process($formMode, $htmlElementNameIdZero);
break;
default:
......@@ -500,7 +500,7 @@ class QuickFormQuery {
* @throws UserFormException
* @internal param $foundInStore
*/
private function validateForm($formNameFoundInStore) {
private function validateForm($formNameFoundInStore, $formMode) {
// Retrieve record_id either from SIP (prefered) or via URL
$r = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_TYPO3 . STORE_CLIENT, '', $recordIdFoundInStore);
......@@ -554,6 +554,7 @@ class QuickFormQuery {
throw new UserFormException("MultiMode selected, but MultiSQL missing", ERROR_MULTI_SQL_MISSING);
}
if ($formMode !== FORM_DELETE) {
$sipArray = $this->store->getStore(STORE_SIP);
// Check: requiredParameter: '' or 'form' or 'form,grId' or 'form #formname for form,grId'
$param = explode(',', $this->formSpec[F_REQUIRED_PARAMETER]);
......@@ -570,6 +571,7 @@ class QuickFormQuery {
throw new UserFormException("Missing required SIP parameter: $name", ERROR_MISSING_REQUIRED_PARAMETER);
}
}
}
return $sipFound;
}
......
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