diff --git a/qfq/AbstractBuildForm.php b/qfq/AbstractBuildForm.php index 46f14ced43bee07cf73c44e547f49db06dbaac18..7c6d6b081cb73fc970e44a6d9421af51de61278a 100644 --- a/qfq/AbstractBuildForm.php +++ b/qfq/AbstractBuildForm.php @@ -109,18 +109,17 @@ abstract class AbstractBuildForm { $parentRecords = $this->db->sql($this->formSpec['multiSql']); foreach ($parentRecords as $row) { - $this->store->setVarArray($row, STORE_PARENT_RECORD); + $this->store->setVarArray($row, STORE_PARENT_RECORD, true); $html .= $this->elements($row['_id'], $filter); } } else { $html .= $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), $filter); } -// $html .= $this->wrapItem(WRAP_SETUP_OUTER, $elementsHtml); - // close the form $html .= $this->tail(); + $html .= $this->doSubrecords(); return $html; @@ -179,12 +178,13 @@ abstract class AbstractBuildForm { /** * Builds the HTML 'form'-tag inlcuding all attributes and target. * + * Notice: the SIP will be transferred as POST Parameter. + * * @return string * @throws DbException */ public function getActionUrl() { - - $queryStringArray['s'] = $this->store->getVar(SIP_SIP, STORE_SIP); + $queryStringArray = array(); Support::appendTypo3ParameterToArray($queryStringArray); @@ -246,7 +246,7 @@ abstract class AbstractBuildForm { // Get default value $value = $formElement['value'] === '' ? $this->store->getVar($formElement['name']) : $value = $formElement['value']; - $htmlFormElementId = $formElement['name'] . ':' . $recordId; + $htmlFormElementId = HelperFormElement::buildFormElementId($formElement['name'], $recordId); // Construct Marshaller Name $buildElementFunctionName = 'build' . $this->buildElementFunctionName[$formElement['type']]; @@ -260,6 +260,9 @@ abstract class AbstractBuildForm { $html .= $this->$buildRowName($formElement, $elementHtml); } + // Log / Debug: Last FormElement has been processed. + $this->store->setVar(SYSTEM_FORM_ELEMENT, '', STORE_SYSTEM); + return $html; } @@ -317,22 +320,28 @@ abstract class AbstractBuildForm { * @throws UserException */ public function buildInput(array $formElement, $htmlFormElementId, $value) { + $textarea = ''; $attribute = $this->getAttribute('name', $htmlFormElementId); $htmlTag = '<input'; - $htmlTagClosing = ''; // Check for input type 'textarea' - $colsRows = explode(',', $formElement['size']); + $colsRows = explode(',', $formElement['size'], 2); if (count($colsRows) === 2) { + // <textarea> $htmlTag = '<textarea'; - $htmlTagClosing = '</textarea>'; $attribute .= $this->getAttribute('cols', $colsRows[0]); $attribute .= $this->getAttribute('rows', $colsRows[1]); + $textarea = htmlentities($value) . '</textarea>'; } else { + // <input> + if ($formElement['maxLength'] > 0) { + $value = substr($value, 0, $formElement['maxLength']); + } $attribute .= $this->getAttributeList($formElement, ['type', 'size', 'maxLength']); + $attribute .= $this->getAttribute('value', htmlentities($value), false); } // 'maxLength' needs an upper 'L': naming convention for DB tables! $attribute .= $this->getAttributeList($formElement, ['autocomplete', 'autofocus', 'placeholder']); @@ -344,9 +353,7 @@ abstract class AbstractBuildForm { $attribute .= $this->getAttributeMode($formElement); - $attribute .= $this->getAttribute('value', htmlentities($value), false); - - return "$htmlTag $attribute>$htmlTagClosing"; + return "$htmlTag $attribute>$textarea"; } /** @@ -643,6 +650,7 @@ abstract class AbstractBuildForm { * @return string */ public function buildCheckboxSingle(array $formElement, $htmlFormElementId, $attribute, $value) { + $html = ''; $attribute .= $this->getAttribute('name', $htmlFormElementId); $attribute .= $this->getAttribute('value', $formElement['checked'], false); @@ -652,7 +660,7 @@ abstract class AbstractBuildForm { $attribute .= $this->getAttributeList($formElement, ['autofocus']); - $html = $this->buildHidden($formElement, $htmlFormElementId, $formElement['unchecked']); +// $html = $this->buildNativeHidden( $htmlFormElementId, $formElement['unchecked']); $html .= '<input ' . $attribute . '>'; if (isset($formElement['label2'])) { @@ -662,16 +670,6 @@ abstract class AbstractBuildForm { return $html; } - /** - * @param array $formElement - * @param $htmlFormElementId - * @param $value - * @return string - */ - public function buildHidden(array $formElement, $htmlFormElementId, $value) { - return '<input type="hidden" name="' . $htmlFormElementId . '" value="' . htmlentities($value) . '">'; - } - /** * @param array $formElement * @param $htmlFormElementId @@ -687,7 +685,7 @@ abstract class AbstractBuildForm { $attributeBase .= $this->getAttribute('name', $htmlFormElementId); - $html = $this->buildHidden($formElement, $htmlFormElementId, $value); + $html = $this->buildNativeHidden($htmlFormElementId, $value); $flagFirst = true; $ii = 0; @@ -715,6 +713,33 @@ abstract class AbstractBuildForm { return $html; } + /** + * Builds a real HTML hidden form element. Usefull for Checkboxes, Multiple-Select and Radios. + * + * @param $htmlFormElementId + * @param $value + * @return string + */ + public function buildNativeHidden($htmlFormElementId, $value) { + return '<input type="hidden" name="' . $htmlFormElementId . '" value="' . htmlentities($value) . '">'; + } + + /** + * Submit hidden values by SIP. + * + * Sometimes, it's usefull to precalculate values during formload and to submit them as hidden fields. + * To avoid any manipulation on those fields, the values will be transferred by SIP. + * + * @param array $formElement + * @param $htmlFormElementId + * @param $value + * @return string + */ + public function buildHidden(array $formElement, $htmlFormElementId, $value) { + + $this->store->setVar($htmlFormElementId, $value, STORE_SIP, false); + } + /** * Build HTML 'radio' element. * @@ -744,7 +769,7 @@ abstract class AbstractBuildForm { $jj = 0; $flagFirst = true; - $html = $this->buildHidden($formElement, $htmlFormElementId, $value); + $html = $this->buildNativeHidden($htmlFormElementId, $value); for ($ii = 0; $ii < count($itemValue); $ii++) { $jj++; $attribute = $attributeBase; @@ -1051,7 +1076,7 @@ abstract class AbstractBuildForm { $html .= $this->wrap[WRAP_SETUP_IN_FIELDSET][WRAP_SETUP_START]; // child FE's - $sql = SQL_FORM_ELEMENT; + $sql = SQL_FORM_ELEMENT_SPECIFIC_CONTAINER; $this->feSpecNative = $this->db->sql($sql, ROW_REGULAR, ['yes', $this->formSpec["id"], 'native,container', $formElement['id']]); HelperFormElement::explodeFieldParameter($this->feSpecNative); $html .= $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_NATIVE_SUBRECORD); @@ -1067,5 +1092,22 @@ abstract class AbstractBuildForm { return $html; } + /** + * Create a new sip, based on latest STORE_SIP Values. Return complete HTML 'hidden' element. + * + * @return string + */ + public function builtNewSip() { + $sipArray = $this->store->getStore(STORE_SIP); + unset($sipArray[SIP_SIP]); + unset($sipArray[SIP_URLPARAM]); + + $queryString = Support::arrayToQueryString($sipArray); + $sip = $this->store->getSip(); + + $sipValue = $sip->queryStringToSip($queryString, RETURN_SIP); + + return $this->buildNativeHidden(CLIENT_SIP, $sipValue); + } } \ No newline at end of file diff --git a/qfq/BuildFormBootstrap.php b/qfq/BuildFormBootstrap.php index 75d5d76c463f6f13a1304c47660d0cbe7c19207c..685b0183ba55675938a9ff918da122a4707984f7 100644 --- a/qfq/BuildFormBootstrap.php +++ b/qfq/BuildFormBootstrap.php @@ -161,6 +161,11 @@ class BuildFormBootstrap extends AbstractBuildForm { return $this->formSpec['name'] . '_' . $id; } + /** + * Simlute Submit Button: http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml + * + * @return string + */ private function buildButtons() { $html = <<<BUTTONS <div class="col-md-2 "> @@ -181,6 +186,7 @@ BUTTONS; return $html; } + /** * Builds the complete HTML '<form ...>'-tag * @@ -200,14 +206,13 @@ BUTTONS; */ public function tail() { $html = ''; - -// $sip = $this->store->getVar(CLIENT_SIP, STORE_CLIENT); -// $sipName = CLIENT_SIP; -// $html .= $this->buildHidden(array(), $sipName, $sip); + $html .= $this->builtNewSip(); // TODO: bootstrap. See BuildFormTable.tail() $html .= '</div> <!--class="tab-content" -->'; // <div class="tab-content"> + $html .= '<input type="submit" value="Submit">'; + $html .= '</form>'; // <form class="form-horizontal" ... $html .= '</div>'; // <div class="container-fluid"> return $html; @@ -225,7 +230,7 @@ BUTTONS; $tmpStore = $this->feSpecNative; // child FE's - $sql = SQL_FORM_ELEMENT; + $sql = SQL_FORM_ELEMENT_SPECIFIC_CONTAINER; $this->feSpecNative = $this->db->sql($sql, ROW_REGULAR, ['yes', $this->formSpec["id"], 'native,container', $formElement['id']]); HelperFormElement::explodeFieldParameter($this->feSpecNative); $html = $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_NATIVE_SUBRECORD); diff --git a/qfq/BuildFormPlain.php b/qfq/BuildFormPlain.php index 7538baedd3be5bb25d496c9e569c952b9fa23118..85b0126b5ef0fe301593ec32e023deb081c0a5f4 100644 --- a/qfq/BuildFormPlain.php +++ b/qfq/BuildFormPlain.php @@ -85,9 +85,7 @@ class BuildFormPlain extends AbstractBuildForm { public function tail() { $html = ''; - $sip = $this->store->getVar(CLIENT_SIP, STORE_CLIENT); - $sipName = CLIENT_SIP; - $html .= $this->buildHidden(array(), $sipName, $sip); + $html .= $this->builtNewSip(); $html .= $this->wrapItem(WRAP_SETUP_INPUT, '<input type="submit" value="Submit">'); $html = $this->wrapItem(WRAP_SETUP_ELEMENT, $html); diff --git a/qfq/BuildFormTable.php b/qfq/BuildFormTable.php index d4f1edd1a62777bd8033358e5e211384a424dc6d..b3a34e40af0a324081b8310be062b559ff5894c2 100644 --- a/qfq/BuildFormTable.php +++ b/qfq/BuildFormTable.php @@ -111,14 +111,12 @@ class BuildFormTable extends AbstractBuildForm { public function tail() { $html = ''; - $sip = $this->store->getVar(CLIENT_SIP, STORE_CLIENT); - $sipName = CLIENT_SIP; $html .= $this->wrapItem(WRAP_SETUP_LABEL, '', false); $html .= $this->wrapItem(WRAP_SETUP_INPUT, '<input type="submit" value="Submit">'); $html = $this->wrapItem(WRAP_SETUP_ELEMENT, $html); $html .= '</table>'; - $html .= $this->buildHidden(array(), $sipName, $sip); + $html .= $this->builtNewSip(); $html .= '</form>'; return $html;