Passed
Branch ops-updates (277b44)
by Björn
05:09
created

UserForm   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 120
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 77
c 1
b 0
f 0
dl 0
loc 120
ccs 0
cts 21
cp 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 118 1
1
<?php
2
/**
3
 * BB's Zend Framework 2 Components
4
 * 
5
 * AdminModule
6
 *
7
 * @package   [MyApplication]
8
 * @package   BB's Zend Framework 2 Components
9
 * @package   AdminModule
10
 * @author    Björn Bartels <[email protected]>
11
 * @link      https://gitlab.bjoernbartels.earth/groups/zf2
12
 * @license   http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
13
 * @copyright copyright (c) 2016 Björn Bartels <[email protected]>
14
 */
15
16
namespace Admin\Form;
17
18
use Zend\Form\Form;
19
20
class UserForm extends Form
21
{
22
    public function __construct($name = null)
23
    {
24
        // we want to ignore the name passed
25
        parent::__construct('user');
26
        
27
        $this->setAttribute('method', 'post');
28
        $this->add(
29
            array(
30
            'name' => 'user_id',
31
            'attributes' => array(
32
            'type'  => 'hidden',
33
            ),
34
            )
35
        );
36
        $this->add(
37
            array(
38
            'name' => 'username',
39
            'attributes' => array(
40
            'type'  => 'text',
41
            ),
42
            'options' => array(
43
            'label' => 'user name',
44
            ),
45
            )
46
        );
47
        $this->add(
48
            array(
49
            'name' => 'email',
50
            'attributes' => array(
51
            'type'  => 'text',
52
            ),
53
            'options' => array(
54
            'label' => 'email',
55
            ),
56
            )
57
        );
58
        $this->add(
59
            array(
60
            'name' => 'display_name',
61
            'attributes' => array(
62
            'type'  => 'text',
63
            ),
64
            'options' => array(
65
            'label' => 'display name',
66
            ),
67
            )
68
        );
69
        $this->add(
70
            array(
71
            'name' => 'password',
72
            'attributes' => array(
73
            'type'  => 'password',
74
            ),
75
            'options' => array(
76
            'label' => 'password',
77
            ),
78
            )
79
        );
80
        $this->add(
81
            array(
82
            'name' => 'state',
83
            'type' => 'select',
84
            'attributes' => array(
85
            'type'  => 'select',
86
            'options'    => array(
87
                    '1'    => 'active',
88
                    '0'    => 'inactive',
89
            ),
90
            ),
91
            'options' => array(
92
            'label' => 'status',
93
            ),
94
            )
95
        );
96
        
97
        $this->add(
98
            array(
99
            'name' => 'aclrole',
100
            'type' => 'select',
101
            'attributes' => array(
102
            'type'  => 'select',
103
            'options'    => array(
104
                    'public' => 'no user',
105
                    'user' => 'user',
106
                    'admin' => 'admin',
107
            ),
108
            ),
109
            'options' => array(
110
            'label' => 'role',
111
            ),
112
            )
113
        );
114
        
115
        
116
        $this->add(
117
            array(
118
            'name' => 'submit',
119
            'attributes' => array(
120
            'type'  => 'submit',
121
            'value' => 'save',
122
            'id' => 'submitbutton',
123
            ),
124
            'options' => array(
125
            'label' => 'save',
126
            ),
127
            )
128
        );
129
        
130
        $this->add(
131
            array(
132
            'name' => 'reset',
133
            'attributes' => array(
134
            'type'  => 'reset',
135
            'value' => 'reset',
136
            'id' => 'resetbutton',
137
            ),
138
            'options' => array(
139
            'label' => 'reset',
140
            ),
141
            )
142
        );
143
    }
144
}