Submit::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 6
ccs 0
cts 5
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Rocket\UI\Forms\Fields;
3
4
/**
5
 * Manage submit field
6
 */
7
8
/**
9
 * Submit field
10
 *
11
 * @author Stéphane Goetz
12
 * @deprecated
13
 */
14
class Submit extends Field
15
{
16
    /**
17
     * Extends the type
18
     * @param string $id
19
     * @param array $data
20
     */
21
    public function __construct($id, $data = [])
22
    {
23
        $this->type = 'submit';
24
25
        parent::__construct($id, $data);
26
    }
27
28
    /**
29
     * Remove the default class
30
     */
31
    protected function classes()
32
    {
33
        $this->label_attributes['class'] = ['columns'];
34
        $this->label_attributes['style']['float'] = 'left';
35
        $this->input_attributes['class'] = ['btn'];
36
        parent::classes();
37
    }
38
39
    /**
40
     * So that we can't set the width
41
     */
42
    protected function applyWidth()
43
    {
44
    }
45
46
    /**
47
     * Adds some specific attributes
48
     */
49
    protected function inputAttributes()
50
    {
51
        $this->input_attributes['name'] = $this->name;
52
        $this->input_attributes['type'] = 'submit';
53
        $this->input_attributes['value'] = $this->params['title'];
54
    }
55
56
    /**
57
     * Adds a title
58
     */
59
    protected function renderTitle()
60
    {
61
        $this->result .= '<span' . $this->renderAttributes($this->span_attributes) . '>&nbsp;</span>';
62
63
        if ($this->params['inline'] == false && $this->params['title'] != ''
64
            && $this->params['label_position'] == 'before') {
65
            $this->result .= '<br />';
66
        }
67
    }
68
69
    /**
70
     * Renders the field
71
     */
72
    protected function renderInner()
73
    {
74
        $this->result .= '<input' . $this->renderAttributes($this->input_attributes) . ' />';
75
    }
76
}
77