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

Wrap Row & Input Elements: specify 'row,/row' and bs*columns to 0 or bigger...

Wrap Row & Input Elements: specify 'row,/row' and bs*columns to 0 or bigger will enable/disable mutliple Elements per Row. FormElement.parameter.wrap* still have precedence over bs*Column settings.

Support.php, AbstractBuildForm.php: Recode way of initializing FormElements.
AbstractBuildForm.php: parameter to limit max number ob templateGrouup Elements.
BuildFormBootstrap.php: Labels will be hided if FormElement.bsLabelColumns=0.
parent 38cbab79
......@@ -387,16 +387,10 @@ abstract class AbstractBuildForm {
$formElement = $this->evaluate->parseArray($fe, $skip, $debugStack);
// Some Defaults
$formElement = Support::setFeDefaults($formElement);
$formElement = Support::setFeDefaults($formElement, $this->formSpec);
if ($flagOutput === true) {
Support::setIfNotSet($formElement, F_BS_LABEL_COLUMNS);
Support::setIfNotSet($formElement, F_BS_INPUT_COLUMNS);
Support::setIfNotSet($formElement, F_BS_NOTE_COLUMNS);
$label = ($formElement[F_BS_LABEL_COLUMNS] == '') ? $this->formSpec[F_BS_LABEL_COLUMNS] : $formElement[F_BS_LABEL_COLUMNS];
$input = ($formElement[F_BS_INPUT_COLUMNS] == '') ? $this->formSpec[F_BS_INPUT_COLUMNS] : $formElement[F_BS_INPUT_COLUMNS];
$note = ($formElement[F_BS_NOTE_COLUMNS] == '') ? $this->formSpec[F_BS_NOTE_COLUMNS] : $formElement[F_BS_NOTE_COLUMNS];
$this->fillWrapLabelInputNote($label, $input, $note);
$this->fillWrapLabelInputNote($formElement[FE_BS_LABEL_COLUMNS], $formElement[FE_BS_INPUT_COLUMNS], $formElement[FE_BS_NOTE_COLUMNS]);
}
//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.
......@@ -937,8 +931,6 @@ abstract class AbstractBuildForm {
* @return string
*/
private function getHelpBlock() {
//TODO: #3066 Class 'hidden' einbauen
// return '<div class="help-block with-errors hidden"></div>';
return '<div class="help-block with-errors hidden"></div>';
}
......@@ -2362,8 +2354,8 @@ abstract class AbstractBuildForm {
$qfqFieldsName = 'qfq_fields_' . $formElement[FE_ID]; // ='qfq-fields'
$templateName = 'template_' . $formElement[FE_ID]; // ='template'
$targetName = 'target_' . $formElement[FE_ID]; // ='template'
Support::setIfNotSet($formElement, FE_VALUE, '5', '');
$max = $formElement[FE_VALUE];
Support::setIfNotSet($formElement, FE_MAX_LENGTH, '5', '');
$max = $formElement[FE_MAX_LENGTH];
$codeJs = <<<EOT
<script type="text/javascript">
......
......@@ -422,37 +422,47 @@ EOF;
// }
/**
* @param array $formElement
* @param string $htmlElement
* @param array $formElement Complete FormElement, especially some FE_WRAP
* @param string $htmlElement Content to wrap.
* @param $htmlFormElementId
* @return string
* @return string Wrapped $htmlElement
* @throws \qfq\UserFormException
*/
public function buildRowNative(array $formElement, $htmlElement, $htmlFormElementId) {
$html = '';
$htmlLabel = '';
if ($formElement[FE_BS_LABEL_COLUMNS] > 0) {
$htmlLabel = $this->buildLabel($htmlFormElementId, $formElement[FE_LABEL]);
$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->customWrap($formElement, $html, FE_WRAP_ROW, [$this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_END]]);
$html .= $this->customWrap($formElement, $htmlLabel, FE_WRAP_LABEL, $formElement[FE_BS_LABEL_COLUMNS], [$this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_END]]);
$html .= $this->customWrap($formElement, $htmlElement, FE_WRAP_INPUT, $formElement[FE_BS_INPUT_COLUMNS], [$this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_END]]);
$html .= $this->customWrap($formElement, $formElement[FE_NOTE], FE_WRAP_NOTE, $formElement[FE_BS_NOTE_COLUMNS], [$this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_END]]);
// ROW
$openTag = (Support::findInSet('row', $formElement[FE_WRAP_ROW_LABEL_INPUT_NOW])) ? $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_START] : '';
$closeTag = (Support::findInSet('/row', $formElement[FE_WRAP_ROW_LABEL_INPUT_NOW])) ? $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_END] : '';
$html = $this->customWrap($formElement, $html, FE_WRAP_ROW, 99, [$openTag, $closeTag]);
return $html;
}
/**
* @param array $formElement
* @param $htmlElement
* @param $wrapName
* @param array $wrapArray
* @return string
*
* @param array $formElement Complete FormElement, especially some FE_WRAP
* @param string $htmlElement Content to wrap.
* @param string $wrapName FE_WRAP_ROW, FE_WRAP_LABEL, FE_WRAP_INPUT, FE_WRAP_NOTE
* @param array $wrapArray Systemwide Defaults: [ 'open wrap', 'close wrap' ]
* @return string Wrapped $htmlElement
* @throws \qfq\UserFormException
*/
private function customWrap(array $formElement, $htmlElement, $wrapName, array $wrapArray) {
private function customWrap(array $formElement, $htmlElement, $wrapName, $bsColumns, array $wrapArray) {
if ($bsColumns == 0) {
$wrapArray[0] = '';
$wrapArray[1] = '';
}
if (isset($formElement[$wrapName])) {
$wrapArray = explode('|', $formElement[$wrapName], 2);
......
......@@ -505,8 +505,14 @@ const FE_VALUE = 'value';
const FE_CLASS = 'class';
const FE_LABEL = 'label';
const FE_NOTE = 'note';
const FE_BS_LABEL_COLUMNS = F_BS_LABEL_COLUMNS;
const FE_BS_INPUT_COLUMNS = F_BS_INPUT_COLUMNS;
const FE_BS_NOTE_COLUMNS = F_BS_NOTE_COLUMNS;
const FE_WRAP_ROW_LABEL_INPUT_NOW = 'rowLabelInputNote';
const FE_MAX_LENGTH = 'maxLength';
const F_FE_PARAMETER = 'parameter'; // valid for F_ and FE_
// FormElement columns: via parameter field
const FE_DATE_FORMAT = 'dateFormat'; // value: FORMAT_DATE_INTERNATIONAL | FORMAT_DATE_GERMAN
const FE_SHOW_SECONDS = 'showSeconds'; // value: 0|1
......
......@@ -563,7 +563,7 @@ class Support {
* @param array $formElement
* @return array
*/
public static function setFeDefaults(array $formElement) {
public static function setFeDefaults(array $formElement, array $formSpec = array()) {
$store = Store::getInstance();
......@@ -572,8 +572,15 @@ class Support {
self::setIfNotSet($formElement, FE_SHOW_ZERO, '0');
self::setIfNotSet($formElement, FE_DATE_FORMAT, $store->getVar(SYSTEM_DATE_FORMAT, STORE_SYSTEM));
if ($formElement[FE_MODE_SQL] != '')
if (count($formSpec) > 0) {
self::setIfNotSet($formElement, F_BS_LABEL_COLUMNS, $formSpec[F_BS_LABEL_COLUMNS], '');
self::setIfNotSet($formElement, F_BS_INPUT_COLUMNS, $formSpec[F_BS_INPUT_COLUMNS], '');
self::setIfNotSet($formElement, F_BS_NOTE_COLUMNS, $formSpec[F_BS_NOTE_COLUMNS], '');
}
if ($formElement[FE_MODE_SQL] != '') {
$formElement[FE_MODE] = $formElement[FE_MODE_SQL];
}
return $formElement;
}
......
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