BuildFormBootstrap.php 20.2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
<?php
/**
 * Created by PhpStorm.
 * User: crose
 * Date: 1/25/16
 * Time: 10:00 PM
 */

namespace qfq;

use qfq;
12
use qfq\UserFormException;
13
14

require_once(__DIR__ . '/../qfq/Constants.php');
15
require_once(__DIR__ . '/../qfq/helper/OnArray.php');
16
require_once(__DIR__ . '/../qfq/AbstractBuildForm.php');
17
require_once(__DIR__ . '/../qfq/exceptions/UserFormException.php');
18

Carsten  Rose's avatar
Carsten Rose committed
19
20
21
22
/**
 * Class BuildFormBootstrap
 * @package qfq
 */
23
24
class BuildFormBootstrap extends AbstractBuildForm {

25
26
27
28
29
30
31
32
33
34
    private $isFirstPill;

    /**
     * @param array $formSpec
     * @param array $feSpecAction
     * @param array $feSpecNative
     */
    public function __construct(array $formSpec, array $feSpecAction, array $feSpecNative) {
        parent::__construct($formSpec, $feSpecAction, $feSpecNative);
        $this->isFirstPill = true;
35
36

        // Set some defaults
37
38
39
//        if (!isset($this->formSpec['class'])) {
//            $this->formSpec['class'] = 'container';
//        }
Carsten  Rose's avatar
Carsten Rose committed
40

41
//        $this->formSpec['class'] = 'none';
42
43
    }

Carsten  Rose's avatar
Carsten Rose committed
44
45
46
    /**
     *
     */
47
    public function fillWrap() {
48
49
50
51

//        $this->wrap[WRAP_SETUP_OUTER][WRAP_SETUP_START] = '<div class="tab-content">';
//        $this->wrap[WRAP_SETUP_OUTER][WRAP_SETUP_END] = '</div>';

52
53
        $this->wrap[WRAP_SETUP_TITLE][WRAP_SETUP_START] = "<div class='row hidden-xs'><div class='col-md-12'><h1>";
        $this->wrap[WRAP_SETUP_TITLE][WRAP_SETUP_END] = "</h1></div></div>";
54

55
        // Element: Label + Input + Note
56
        $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_START] = "<div class='form-group clearfix'>";
57
        $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_END] = "</div>";
58

59
60
        $this->wrap[WRAP_SETUP_SUBRECORD][WRAP_SETUP_START] = "<div class='col-md-12'>";
        $this->wrap[WRAP_SETUP_SUBRECORD][WRAP_SETUP_END] = "</div>";
61

62
63
        $this->wrap[WRAP_SETUP_IN_FIELDSET][WRAP_SETUP_START] = "";
        $this->wrap[WRAP_SETUP_IN_FIELDSET][WRAP_SETUP_END] = "";
64

65
66
67
        $this->wrap[WRAP_SETUP_IN_TEMPLATE_GROUP][WRAP_SETUP_START] = "";
        $this->wrap[WRAP_SETUP_IN_TEMPLATE_GROUP][WRAP_SETUP_END] = "";

68
69
//        $this->feDivClass['radio'] = 'radio';
//        $this->feDivClass['checkbox'] = 'checkbox';
70
71
    }

72
73
74
75
76
77
    /**
     * @param $label
     * @param $input
     * @param $note
     */
    public function fillWrapLabelInputNote($label, $input, $note) {
78
        $this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_START] = "<div class='col-md-$label qfq-label'>";
79
80
81
        $this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_END] = "</div>";
        $this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_START] = "<div class='col-md-$input'>";
        $this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_END] = "</div>";
Carsten  Rose's avatar
Carsten Rose committed
82
        $this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_START] = "<div class='col-md-$note qfq-note'>";
83
84
85
86
        $this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_END] = "</div>";

    }

Carsten  Rose's avatar
Carsten Rose committed
87
88
89
    /**
     * @return string
     */
90
91
92
93
    public function getProcessFilter() {
        return FORM_ELEMENTS_NATIVE_SUBRECORD;
    }

Carsten  Rose's avatar
Carsten Rose committed
94
95
96
    /**
     * @return string
     */
97
98
99
100
101
102
103
104
    public function doSubrecords() {
        return '';
    }

    /**
     * @return string
     */
    public function head() {
105
        $html = '';
106

107
        $html .= '<div ' . Support::doAttribute('class', $this->formSpec[F_CLASS], TRUE) . '>'; // main <div class=...> around everything, Whole FORM; class="container" or class="container-fluid"
108

109
        //TODO: nicer error reporting - make test with 'unknown index' here - unset($this->formSpec['title']) - See #3424
110
111
112
        $title = Support::wrapTag('<div class="hidden-xs col-sm-6 col-md-8">', Support::wrapTag('<h3>', $this->formSpec['title']));
        $button = Support::wrapTag('<div class="col-xs-12 col-sm-6 col-md-4">', $this->buildButtons());
        $html .= Support::wrapTag('<div class="row">', $title . $button);
113
114


115
116
        $pill = $this->buildPillNavigation(OnArray::filter($this->feSpecNative, 'type', 'pill'));
        $html .= Support::wrapTag('<div class="row">', $pill);
117

118
119
        $html .= $this->getFormTag();

120
121
122
123
124
        $class = ['tab-content', $this->formSpec[F_CLASS_BODY]];
        if ($pill == '') {
            $class[] = 'col-md-12';
        }
        $html .= "<div " . Support::doAttribute('class', $class) . ">";
125
126
127
128

        return $html;
    }

129
130
131
132
133
134
135
136
137
138
139
140
141
142
    /**
     * Creates a Checkbox, which toggles 'hide'/'unhide' via JS, on all elements with class= CLASS_FORM_ELEMENT_EDIT.
     *
     * @return string - the rendered Checkbox
     */
    private function buildShowEditFormElementCheckbox() {
        $js = '$(".' . CLASS_FORM_ELEMENT_EDIT . '").toggleClass("hidden")';
        $element = "<input type='checkbox' onchange='" . $js . "'>" .
            Support::wrapTag("<span class='" . GLYPH_ICON . ' ' . GLYPH_ICON_TASKS . "'>", '');

        $element = Support::wrapTag('<label class="btn btn-default navbar-btn">', $element);
        return Support::wrapTag('<div class="btn-group" data-toggle="buttons">', $element);
    }

143
    /**
144
     * Build Buttons panel on top right corner of form.
145
     * Simulate Submit Button: http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml
146
147
148
149
150
     *
     * @return string
     */
    private function buildButtons() {
        $buttonNew = '';
151
152
153
154
        $buttonDelete = '';
        $buttonClose = '';
        $buttonSave = '';
        $buttonEditForm = '';
Carsten  Rose's avatar
Carsten Rose committed
155
156
157
158
159
        $recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP);


        // Button: FormEdit
        if ($this->showDebugInfo) {
160
            $toolTip = "Edit form" . PHP_EOL . PHP_EOL . OnArray::toString($this->store->getStore(STORE_SIP), ' = ', PHP_EOL, "'");
161
            $url = $this->createFormEditorUrl(FORM_NAME_FORM, $this->formSpec[F_ID]);
162

163
            $buttonEditForm = $this->buildShowEditFormElementCheckbox() . $this->buildButtonAnchor('form-edit-button', $url, $toolTip, GLYPH_ICON_TOOL);
164
165
166
        }

        // Button: Save
167
        if (Support::findInSet(FORM_BUTTON_SAVE, $this->formSpec['showButton']) && $this->formSpec[F_SUBMIT_BUTTON_TEXT] === '') {
168
169
170
            $toolTip = 'Save';

            if ($this->showDebugInfo) {
171
                $toolTip .= PHP_EOL . "table = '" . $this->formSpec[F_TABLE_NAME] . "'" . PHP_EOL . "r = '" . $recordId . "'";
172
173
            }

174
            $buttonSave = $this->buildButtonCode('save-button', $toolTip, GLYPH_ICON_CHECK, '', $this->formSpec[F_BUTTON_ON_CHANGE_CLASS]);
175
176
177
178
179
180
        }

        // Button: Close
        if (Support::findInSet(FORM_BUTTON_CLOSE, $this->formSpec['showButton'])) {
            $toolTip = 'Close';

181
            $buttonClose = $this->buildButtonCode('close-button', 'Close', GLYPH_ICON_CLOSE);
Carsten  Rose's avatar
Carsten Rose committed
182
        }
183

Carsten  Rose's avatar
Carsten Rose committed
184
        // Button: Delete
185
        if (Support::findInSet(FORM_BUTTON_DELETE, $this->formSpec['showButton'])) {
186
187
            $toolTip = 'Delete';

Carsten  Rose's avatar
Carsten Rose committed
188
            if ($this->showDebugInfo && $recordId > 0) {
189
                $toolTip .= PHP_EOL . "form = '" . $this->formSpec[F_FINAL_DELETE_FORM] . "'" . PHP_EOL . "r = '" . $recordId . "'";
Carsten  Rose's avatar
Carsten Rose committed
190
            }
191
            $disabled = ($recordId > 0) ? '' : 'disabled';
Carsten  Rose's avatar
Carsten Rose committed
192

193
            $buttonDelete = $this->buildButtonCode('delete-button', $toolTip, GLYPH_ICON_DELETE, $disabled);
194
195
        }

Carsten  Rose's avatar
Carsten Rose committed
196
        // Button: New
197
        if (Support::findInSet(FORM_BUTTON_NEW, $this->formSpec['showButton'])) {
198
199
            $toolTip = 'New';
            $url = $this->deriveNewRecordUrlFromExistingSip($toolTip);
Carsten  Rose's avatar
Carsten Rose committed
200

201
            $buttonNew = $this->buildButtonAnchor('form-new-button', $url, $toolTip, GLYPH_ICON_NEW);
202
203
        }

204
        // Arrangement: Edit Form / Save / Close / Delete / New
Carsten  Rose's avatar
Carsten Rose committed
205
        // Specified in reverse order cause 'pull-right' inverts the order. http://getbootstrap.com/css/#helper-classes-floats
206
207
208
209
210
        $html = '';
        $html .= Support::wrapTag('<div class="btn-group pull-right" role="group">', $buttonNew);
        $html .= Support::wrapTag('<div class="btn-group pull-right" role="group">', $buttonDelete);
        $html .= Support::wrapTag('<div class="btn-group pull-right" role="group">', $buttonSave . $buttonClose);
        $html .= Support::wrapTag('<div class="btn-group pull-right" role="group">', $buttonEditForm);
211
212
213

        $html = Support::wrapTag('<div class="btn-toolbar" role="toolbar">', $html);

214
215
216
        return $html;
    }

217
218
219
220
221
222
223
224
225
    /**
     * @param $id
     * @param $url
     * @param $title
     * @param $icon
     * @param string $disabled
     * @return string
     */
    private function buildButtonAnchor($id, $url, $title, $icon, $disabled = '') {
226
        return "<a " . Support::doAttribute('href', $url) . " id='$id' class='btn btn-default navbar-btn $disabled' " . Support::doAttribute('title', $title) . "><span class='glyphicon $icon'></span></a>";
227
228
229
    }

    /**
230
231
     * Creates a button with the given attributes. If there is no $icon given, render the button without glyph.
     *
232
233
234
     * @param string $id
     * @param string $title
     * @param string $icon
235
236
237
     * @param string $disabled
     * @return string
     */
238
    private function buildButtonCode($id, $title, $icon, $disabled = '', $buttonOnChangeClass = '') {
239
240
241
242
243
244
245
246
247

        $element = "<span class='glyphicon $icon'></span>";
        $classAdd = "navbar-btn";

        if ($icon === '') {
            $element = $title;
            $classAdd = '';
        }

248
        $class = Support::doAttribute('class', ["btn btn-default", $classAdd]);
249
        $dataClassOnChange = Support::doAttribute('data-class-on-change', $buttonOnChangeClass);
250
        $title = Support::doAttribute('title', $title);
251
        return "<button id='$id' type='button' $class $dataClassOnChange $title $disabled>$element</button>";
252
253
    }

Carsten  Rose's avatar
Carsten Rose committed
254
    /**
255
     * @param $pillArray
Carsten  Rose's avatar
Carsten Rose committed
256
     * @return string
257
     * @throws UserFormException
Carsten  Rose's avatar
Carsten Rose committed
258
     */
259
260
261
    private function buildPillNavigation($pillArray) {
        $pillButton = '';
        $pillDropdown = '';
262
        $htmlDropdown = '';
263
264
265
266
267
268
269
270
271
272
273
274

        if ($pillArray == null)
            return '';

        $maxVisiblePill = (isset($this->formSpec['maxVisiblePill']) && $this->formSpec['maxVisiblePill'] !== '') ? $this->formSpec['maxVisiblePill'] : 1000;

        // Iterate over all 'pill'
        $ii = 0;
        $active = 'class="active"';
        foreach ($pillArray as $formElement) {
            $ii++;

275
            if ($formElement[FE_NAME] === '' || $formElement[FE_LABEL] === '') {
276
                $this->store->setVar(SYSTEM_FORM_ELEMENT, Logger::formatFormElementName($formElement), STORE_SYSTEM);
277
                $this->store->setVar(SYSTEM_FORM_ELEMENT_COLUMN, 'name, label', STORE_SYSTEM);
278
                throw new UserFormException("Field 'name' and/or 'label' are empty", ERROR_NAME_LABEL_EMPTY);
279
280
            }

281
            // Anker for pill navigation
282
            $a = '<a ' . Support::doAttribute('href', '#' . $this->createAnker($formElement['id'])) . ' data-toggle="tab">' . $formElement[FE_LABEL] . '</a>';
283

284
285
286
287
288
289
290
            if ($ii <= $maxVisiblePill) {
                $pillButton .= '<li role="presentation" ' . $active . '>' . $a . '</li>';
            } else {
                $pillDropdown .= '<li>' . $a . '</li>';
            }
            $active = '';
        }
291

292
293
        // Pill Dropdown necessary?
        if ($ii > $maxVisiblePill) {
294
            $htmlDropdown = Support::wrapTag('<ul class="dropdown-menu qfq-form-pill ' . $this->formSpec[F_CLASS_PILL] . '">', $pillDropdown, true);
295
            $htmlDropdown = '<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button">more <span class="caret"></span></a>' . $htmlDropdown;
296
            $htmlDropdown = Support::wrapTag('<li role="presentation" class="dropdown">', $htmlDropdown, false);
297
        }
298

299
        $htmlDropdown = Support::wrapTag('<ul id="' . $this->getTabId() . '" class="nav nav-pills qfq-form-pill ' . $this->formSpec[F_CLASS_PILL] . '" role="tablist">', $pillButton . $htmlDropdown);
300
        $htmlDropdown = Support::wrapTag('<div class="col-md-12">', $htmlDropdown);
301

302
        return $htmlDropdown;
303
304
305
306
307
308
309
310
311
312
313
314
    }

    /**
     * Create an identifier for the pill navigation menu
     *
     * @param $id
     * @return string
     */
    private function createAnker($id) {
        return $this->formSpec['name'] . '_' . $id;
    }

Carsten  Rose's avatar
Carsten Rose committed
315
316
317
318
319
320
321
    /**
     * @return string
     */
    private function getTabId() {
        return 'qfqTabs';
    }

322
323
324
325
326
    /**
     * Builds the complete HTML '<form ...>'-tag
     *
     * @return string
     */
327
    public function getFormTag() {
328
329
330
331

        $attribute = $this->getFormTagAtrributes();

        $attribute['class'] = 'form-horizontal';
332
        $attribute['data-toggle'] = 'validator';
333
334
335
336

        return '<form ' . OnArray::toString($attribute, '=', ' ', "'") . '>';
    }

337
338
339
340
    /**
     * @return string
     */
    public function tail() {
341

342
        $html = '';
Carsten  Rose's avatar
Carsten Rose committed
343
        $deleteUrl = '';
344

345
346
        $formId = $this->getFormId();

347
348
        // Button Save at bottom of form - only if there is a button text given.
        if ($this->formSpec[F_SUBMIT_BUTTON_TEXT] !== '') {
349
350
351
352
353


            // Default setzen:
            $this->fillWrapLabelInputNote($this->formSpec[F_BS_LABEL_COLUMNS], $this->formSpec[F_BS_INPUT_COLUMNS], $this->formSpec[F_BS_NOTE_COLUMNS]);

354
355
            $buttonText = $this->formSpec[F_SUBMIT_BUTTON_TEXT];

356
            $htmlElement = $this->buildButtonCode('save-button', $buttonText, '', '', $this->formSpec[F_BUTTON_ON_CHANGE_CLASS]);
357
358
359
360
361
362
363
364

            $html .= $this->wrapItem(WRAP_SETUP_LABEL, '');
            $html .= $this->wrapItem(WRAP_SETUP_INPUT, $htmlElement);
            $html .= $this->wrapItem(WRAP_SETUP_NOTE, '');

            $html = $this->wrapItem(WRAP_SETUP_ELEMENT, $html);
        }

365
        $html .= '</div> <!--class="tab-content" -->';  //  <div class="tab-content">
366
//        $html .= '<input type="submit" value="Submit">';
367

Carsten  Rose's avatar
Carsten Rose committed
368
369
370
        $formId = $this->getFormId();
        $tabId = $this->getTabId();

Carsten  Rose's avatar
Carsten Rose committed
371
        if (0 < ($recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP))) {
372
            $deleteUrl = $this->createDeleteUrl($this->formSpec[F_FINAL_DELETE_FORM], '', $recordId);
Carsten  Rose's avatar
Carsten Rose committed
373
        }
374

375
376
377
        $actionUpload = FILE_ACTION . '=' . FILE_ACTION_UPLOAD;
        $actionDelete = FILE_ACTION . '=' . FILE_ACTION_DELETE;

378
379
380
        $apiDir = API_DIR;
        $apiDeletePhp = API_DIR . '/' . API_DELETE_PHP;

381
        $html .= '</form>';  //  <form class="form-horizontal" ...
382
383
384
385
386
387
        $html .= <<<EOF
        <script type="text/javascript">
            $(function () {
                'use strict';
                QfqNS.Log.level = 0;

Carsten  Rose's avatar
Carsten Rose committed
388
389
390
                var qfqPage = new QfqNS.QfqPage({
                    tabsId: '$tabId',
                    formId: '$formId',
391
                    submitTo: '$apiDir/save.php',
Carsten  Rose's avatar
Carsten Rose committed
392
                    deleteUrl: '$deleteUrl',
393
394
395
                    refreshUrl: '$apiDir/load.php',
                    fileUploadTo: '$apiDir/file.php?$actionUpload',
                    fileDeleteUrl: '$apiDir/file.php?$actionDelete'
Carsten  Rose's avatar
Carsten Rose committed
396
397
                });

398
                var qfqRecordList = new QfqNS.QfqRecordList('$apiDeletePhp');
Carsten  Rose's avatar
Carsten Rose committed
399
            })
400
401
         </script>
EOF;
402
        $html .= '</div>';  //  <div class="container-fluid"> === main <div class=...> around everything
403

404
405
406
407
408
        return $html;
    }

    /**
     * @param array $formElement
409
     * @param $htmlFormElementName
410
411
412
     * @param $value
     * @return mixed
     */
413
    public function buildPill(array $formElement, $htmlFormElementName, $value, array &$json) {
414
        $html = '';
415
416
417
418
        // save parent processed FE's
        $tmpStore = $this->feSpecNative;

        // child FE's
419
420
421
        $this->feSpecNative = $this->db->getNativeFormElements(SQL_FORM_ELEMENT_SPECIFIC_CONTAINER,
            ['yes', $this->formSpec["id"], 'native,container', $formElement['id']], $this->formSpec);

Carsten  Rose's avatar
Carsten Rose committed
422
        $html = $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_NATIVE_SUBRECORD, 0, $json);
423
424
425
426

        // restore parent processed FE's
        $this->feSpecNative = $tmpStore;

427
428
429
        return $html;
    }

430
    /**
431
432
     * @param array $formElement Complete FormElement, especially some FE_WRAP
     * @param string $htmlElement Content to wrap.
433
     * @param $htmlFormElementName
434
     * @return string               Wrapped $htmlElement
435
     * @throws \qfq\UserFormException
436
     */
437
    public function buildRowNative(array $formElement, $htmlElement, $htmlFormElementName) {
438
        $html = '';
439
        $htmlLabel = '';
440

Carsten  Rose's avatar
Carsten Rose committed
441
        // Label
442
        if ($formElement[FE_BS_LABEL_COLUMNS] > 0) {
443
            $htmlLabel = $this->buildLabel($htmlFormElementName, $formElement[FE_LABEL]);
444
        }
445

446
        $html .= $this->customWrap($formElement, $htmlLabel, FE_WRAP_LABEL, $formElement[FE_BS_LABEL_COLUMNS],
447
            [$this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_END]], $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_LABEL);
448

Carsten  Rose's avatar
Carsten Rose committed
449
        // Input
450
        $html .= $this->customWrap($formElement, $htmlElement, FE_WRAP_INPUT, $formElement[FE_BS_INPUT_COLUMNS],
451
            [$this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_END]], $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_INPUT);
452

Carsten  Rose's avatar
Carsten Rose committed
453
        // Note
Carsten  Rose's avatar
Carsten Rose committed
454
        $note = $formElement[FE_NOTE];
455
        $html .= $this->customWrap($formElement, $note, FE_WRAP_NOTE, $formElement[FE_BS_NOTE_COLUMNS],
456
            [$this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_END]], $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_NOTE);
457
458
459
460

        // 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] : '';
461
        $html = $this->customWrap($formElement, $html, FE_WRAP_ROW, 99, [$openTag, $closeTag], $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_ROW);
462
463
464
465

        return $html;
    }

466
    /**
467
468
469
470
     *
     * @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
471
     * @param int $bsColumns
472
     * @param array $wrapArray Systemwide Defaults: [ 'open wrap', 'close wrap' ]
473
     * @return string Wrapped $htmlElement
474
475
     * @throws \qfq\UserFormException
     */
476
    private function customWrap(array $formElement, $htmlElement, $wrapName, $bsColumns, array $wrapArray, $htmlId = '') {
477

478
        // If $bsColumns==0: do not wrap with default.
479
480
481
482
        if ($bsColumns == 0) {
            $wrapArray[0] = '';
            $wrapArray[1] = '';
        }
483

484
        // If there is a 'per FormElement'-wrap, take it.
485
486
487
488
489
490
491
492
        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);
        }

493
494
495
496
        if ($wrapArray[0] != '') {
            $wrapArray[0] = Support::insertAttribute($wrapArray[0], 'id', $htmlId);
        }

497
498
499
        return $wrapArray[0] . $htmlElement . $wrapArray[1];
    }

500
501
502
503
504
    /**
     * @param $formElement
     * @param $elementHtml
     * @return string
     */
505
    public function buildRowPill(array $formElement, $elementHtml) {
506
507
        $html = '';

508
        $html .= Support::wrapTag('<div class="col-md-12 qfq-form-body ' . $this->formSpec[F_CLASS_BODY] . '">', $elementHtml);
509
510
511

        $active = $this->isFirstPill ? ' active' : '';

512
        $html = Support::wrapTag('<div role="tabpanel" class="tab-pane' . $active . '" id="' . $this->createAnker($formElement['id']) . '">', $html);
513
514
515
516
517
518

        $this->isFirstPill = false;

        return $html;
    }

519
    /**
520
521
     * Builds a fieldset
     *
522
523
524
     * @param $formElement
     * @param $elementHtml
     */
525
    public function buildRowFieldset(array $formElement, $elementHtml) {
526
527
528
        $html = $elementHtml;

        return $html;
529
530
    }

531
532
533
534
535
536
537
538
539
540
541
542
    /**
     * Builds a templateGroup
     *
     * @param $formElement
     * @param $elementHtml
     */
    public function buildRowTemplateGroup(array $formElement, $elementHtml) {
        $html = $elementHtml;

        return $html;
    }

543
544
545
546
547
    /**
     * @param $formElement
     * @param $elementHtml
     * @return string
     */
548
    public function buildRowSubrecord(array $formElement, $elementHtml) {
549
        $html = '';
550
        $html .= $this->wrapItem(WRAP_SETUP_ELEMENT, $this->wrapItem(WRAP_SETUP_SUBRECORD, $formElement[FE_LABEL]));
551
        $html .= $this->wrapItem(WRAP_SETUP_ELEMENT, $this->wrapItem(WRAP_SETUP_SUBRECORD, $elementHtml));
552
        $html .= $this->wrapItem(WRAP_SETUP_ELEMENT, $this->wrapItem(WRAP_SETUP_SUBRECORD, $formElement[FE_NOTE]));
553
554
555

        return $html;
    }
556
}