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

HelperFormElement.php, AbstractBuildForm.php, Constants.php: 'Retype function'...

HelperFormElement.php, AbstractBuildForm.php, Constants.php: 'Retype function' - default value will be copied to second element. Detection of secondary-'retype'-FormElement can be done by isset($fe[FE_RETYPE_SOURCE_NAME])  .
parent 670cf8df
......@@ -384,15 +384,16 @@ abstract class AbstractBuildForm {
$this->fillWrapLabelInputNote($label, $input, $note);
}
//TODO: hier den Defaultvalue fuer RETYPE Elemente bestimmen.
//In case the current element is a 'RETYPE' element: take the element name of the source FormElement. Needed in the next row to retrieve the default value.
$name = (isset($formElement[FE_RETYPE_SOURCE_NAME])) ? $formElement[FE_RETYPE_SOURCE_NAME] : $formElement[FE_NAME];
// Get default value
$value = ($formElement[FE_VALUE] === '') ? $this->store->getVar($formElement['name'], $storeUse,
$value = ($formElement[FE_VALUE] === '') ? $this->store->getVar($name, $storeUse,
$formElement['checkType']) : $formElement[FE_VALUE];
// Typically: $htmlElementNameIdZero = true
// After Saving a record, staying on the form, the FormElements on the Client are still known as '<feName>:0'.
$htmlFormElementId = HelperFormElement::buildFormElementName($formElement['name'], ($htmlElementNameIdZero) ? 0 : $recordId);
$htmlFormElementId = HelperFormElement::buildFormElementName($formElement[FE_NAME], ($htmlElementNameIdZero) ? 0 : $recordId);
// Construct Marshaller Name: buildElement
$buildElementFunctionName = 'build' . $this->buildElementFunctionName[$formElement[FE_TYPE]];
......@@ -673,7 +674,7 @@ abstract class AbstractBuildForm {
// $attribute .= Support::doAttribute('data-compare-element', $htmlFormElementIdRetype);
// }
if (substr($formElement[FE_NAME], -6) == RETYPE_FE_NAME_EXTENSION) {
if (isset($formElement[FE_RETYPE_SOURCE_NAME])) {
$htmlFormElementIdPrimary = str_replace(RETYPE_FE_NAME_EXTENSION, '', $htmlFormElementId);
$attribute .= Support::doAttribute('data-match', '[name=' . str_replace(':', '\\:', $htmlFormElementIdPrimary) . ']');
}
......
......@@ -508,6 +508,7 @@ const FE_AUTOFOCUS = 'autofocus'; // value: <none>|0|1 , <none>==1, this elemen
const FE_RETYPE = 'retype'; // value: <none>|0|1 , <none>==1, this element becomes the focus during form load.
const FE_RETYPE_LABEL = 'retypeLabel'; // value: label text for retype FormElement
const FE_RETYPE_NOTE = 'retypeNote'; // value: note text for retype FormElement
const FE_RETYPE_SOURCE_NAME = '_retypeSourceName'; // QFQ internal reference to name of source FormElement.
const RETYPE_FE_NAME_EXTENSION = 'RETYPE';
......
......@@ -107,6 +107,8 @@ class HelperFormElement
if (isset($fe[FE_RETYPE]) && $fe[FE_RETYPE] == '1') {
// Reference to Source FormElement
$fe[FE_RETYPE_SOURCE_NAME] = $fe[FE_NAME];
// Create copy of FE, adjust name, label, note
$fe[FE_NAME] .= RETYPE_FE_NAME_EXTENSION;
......
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