Completed
Push — master ( 29f185...9200bf )
by Michael
18s
created

BlockForm::render()   B

Complexity

Conditions 5
Paths 7

Size

Total Lines 23
Code Lines 17

Duplication

Lines 23
Ratio 100 %

Code Coverage

Tests 15
CRAP Score 5.0061

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 23
loc 23
ccs 15
cts 16
cp 0.9375
rs 8.5906
cc 5
eloc 17
nc 7
nop 0
crap 5.0061
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
namespace Xoops\Form;
13
14
/**
15
 * BlockForm - Form that will output formatted as a HTML table
16
 *
17
 * No styles and no JavaScript to check for required fields.
18
 *
19
 * @category  Xoops\Form\BlockForm
20
 * @package   Xoops\Form
21
 * @author    trabis <[email protected]>
22
 * @copyright 2012-2016 XOOPS Project (http://xoops.org)
23
 * @license   GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
24
 * @link      http://xoops.org
25
 */
26
class BlockForm extends Form
27
{
28
    /**
29
     * __construct
30
     */
31 2
    public function __construct()
32
    {
33 2
        parent::__construct('', '', '');
34 2
    }
35
36
    /**
37
     * render
38
     *
39
     * @return string
40
     */
41 2 View Code Duplication
    public function render()
42
    {
43 2
        $ret = '<div>';
44
        /* @var $ele Element */
45 2
        foreach ($this->getElements() as $ele) {
46 2
            if ($ele->has('datalist')) {
47
                $ret .= $ele->renderDatalist();
48
            }
49 2
            if (!$ele->isHidden()) {
50 2
                $ret .= '<div class="form-group">';
51 2
                $ret .= '<label>' . $ele->getCaption();
52 2
                $ret .= ($ele->isRequired() ? '<span class="caption-required">*</span>' : '') . '</label>';
53 2
                $ret .= $ele->render();
54 2
                $ret .= '<small class="text-muted">' . $ele->getDescription() . '</small>';
55 2
                $ret .= '<p class="dsc_pattern_vertical">' . $ele->getPatternDescription() . '</p>';
56 2
                $ret .= '</div>' . "\n";
57
            } else {
58 2
                $ret .= $ele->render(). "\n";
59
            }
60
        }
61 2
        $ret .= '</div>';
62 2
        return $ret;
63
    }
64
}
65