FormFieldsView::view()   A
last analyzed

Complexity

Conditions 5
Paths 6

Size

Total Lines 30
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 5

Importance

Changes 0
Metric Value
cc 5
eloc 18
nc 6
nop 4
dl 0
loc 30
ccs 18
cts 18
cp 1
crap 5
rs 9.3554
c 0
b 0
f 0
1
<?php namespace Distilleries\FormBuilder\Fields;
2
3
use Kris\LaravelFormBuilder\Fields\FormField;
4
5
abstract class FormFieldsView extends FormField {
6
7 40
    public function view(array $options = [], $showLabel = true, $showField = true, $showError = false)
8
    {
9
10 40
        $this->rendered = true;
11 40
        $options        = $this->prepareOptions($options);
12
13 40
        if (!$this->needsLabel($options))
14
        {
15 8
            $showLabel = false;
16
        }
17
18 40
        if (!empty($options['noInEditView']) && $options['noInEditView'] === true) {
19 2
            return '';
20
        }
21
22 38
        if (isset($options['default_value'])) {
23 12
            $options['value'] = $options['default_value'];
24
        }
25
26 38
        return $this->formHelper->getView()->make(
27 38
            $this->template, [
28 38
                'name'      => $this->name,
29 38
                'type'      => $this->type,
30 38
                'options'   => $options,
31
                'noEdit'    => true,
32 38
                'showLabel' => $showLabel,
33 38
                'showField' => $showField,
34 38
                'showError' => $showError
35
            ])
36 38
            ->render();
37
    }
38
}