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

Implemented for FormElement: wrapRow, wrapLabel, wrapInput, wrapNote

FormElement.rowLabelInputNote are not respected anymore.

AbstractBuildForm.php: cleanup
BuildFormBootsrap.php: new function customWrap()
Constants.php: new wrapRow, wrapLabel, wrapInput, wrapNote
parent 5e9588a6
......@@ -245,8 +245,11 @@ abstract class AbstractBuildForm {
* @return string
*/
public function wrapItem($item, $value, $flagOmitEmpty = false) {
if ($flagOmitEmpty && $value === "")
if ($flagOmitEmpty && $value === "") {
return '';
}
return $this->wrap[$item][WRAP_SETUP_START] . $value . $this->wrap[$item][WRAP_SETUP_END];
}
......
......@@ -399,6 +399,25 @@ EOF;
return $html;
}
/**
* @param array $formElement
* @param string $htmlElement
* @return string
*/
// public function buildRowNative(array $formElement, $htmlElement, $htmlFormElementId) {
// $html = '';
//
// $htmlLabel = $this->buildLabel($htmlFormElementId, $formElement[FE_LABEL]);
//
// $html .= $this->wrapItem(WRAP_SETUP_LABEL, $htmlLabel);
// $html .= $this->wrapItem(WRAP_SETUP_INPUT, $htmlElement);
// $html .= $this->wrapItem(WRAP_SETUP_NOTE, $formElement[FE_NOTE], true);
//
// $html = $this->wrapItem(WRAP_SETUP_ELEMENT, $html);
//
// return $html;
// }
/**
* @param array $formElement
* @param string $htmlElement
......@@ -409,15 +428,38 @@ EOF;
$htmlLabel = $this->buildLabel($htmlFormElementId, $formElement[FE_LABEL]);
$html .= $this->wrapItem(WRAP_SETUP_LABEL, $htmlLabel);
$html .= $this->wrapItem(WRAP_SETUP_INPUT, $htmlElement);
$html .= $this->wrapItem(WRAP_SETUP_NOTE, $formElement[FE_NOTE], true);
$html .= $this->customWrap($formElement, $htmlLabel, FE_WRAP_LABEL, [$this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_END]]);
$html .= $this->customWrap($formElement, $htmlElement, FE_WRAP_INPUT, [$this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_END]]);
if ($formElement[FE_NOTE] != '') {
$html .= $this->customWrap($formElement, $formElement[FE_NOTE], FE_WRAP_NOTE, [$this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_END]]);
}
$html = $this->wrapItem(WRAP_SETUP_ELEMENT, $html);
$html = $this->customWrap($formElement, $html, FE_WRAP_ROW, [$this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_END]]);
return $html;
}
/**
* @param array $formElement
* @param $htmlElement
* @param $wrapName
* @param array $wrapArray
* @return string
* @throws \qfq\UserFormException
*/
private function customWrap(array $formElement, $htmlElement, $wrapName, array $wrapArray) {
if (isset($formElement[$wrapName])) {
$wrapArray = explode('|', $formElement[$wrapName], 2);
}
if (count($wrapArray) != 2) {
throw new UserFormException("Need open & close wrap token for FormElement.parameter" . $wrapName . " - E.g.: <div ...>|</div>", ERROR_MISSING_VALUE);
}
return $wrapArray[0] . $htmlElement . $wrapArray[1];
}
/**
* @param $formElement
* @param $elementHtml
......
......@@ -537,6 +537,10 @@ const FE_RETYPE = 'retype'; // value: <none>|0|1 , <none>==1, this element beco
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 FE_WRAP_ROW = 'wrapRow';
const FE_WRAP_LABEL = 'wrapLabel';
const FE_WRAP_INPUT = 'wrapInput';
const FE_WRAP_NOTE = 'wrapNote';
const RETYPE_FE_NAME_EXTENSION = 'RETYPE';
......
......@@ -86,7 +86,7 @@ CREATE TABLE IF NOT EXISTS `FormElement` (
`bsLabelColumns` VARCHAR(255) NOT NULL DEFAULT '',
`bsInputColumns` VARCHAR(255) NOT NULL DEFAULT '',
`bsNoteColumns` VARCHAR(255) NOT NULL DEFAULT '',
`labelInputNote` SET('row', 'label', '/label', 'input', '/input', 'note', '/note', '/row') NOT NULL DEFAULT 'row,label,/label,input,/input,note,/note,/row',
`rowLabelInputNote` SET('row', 'label', '/label', 'input', '/input', 'note', '/note', '/row') NOT NULL DEFAULT 'row,label,/label,input,/input,note,/note,/row',
`note` TEXT NOT NULL,
`tooltip` VARCHAR(255) NOT NULL DEFAULT '',
`placeholder` VARCHAR(255) NOT NULL DEFAULT '',
......
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