Completed
Pull Request — develop (#323)
by Mathias
15:36
created

AddItemFieldset   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 70
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B init() 0 40 1
A getInputFilterSpecification() 0 17 1
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @license MIT
7
 * @copyright  2013 - 2016 Cross Solution <http://cross-solution.de>
8
 */
9
  
10
/** */
11
namespace Core\Form\Tree;
12
13
use Core\Form\ViewPartialProviderInterface;
14
use Core\Form\ViewPartialProviderTrait;
15
use Zend\Form\Fieldset;
16
use Zend\InputFilter\InputFilterProviderInterface;
17
18
/**
19
 * Fieldset for adding a tree item.
20
 * 
21
 * @author Mathias Gelhausen <[email protected]>
22
 * @since 0.29
23
 */
24
class AddItemFieldset extends Fieldset implements ViewPartialProviderInterface, InputFilterProviderInterface
25
{
26
    use ViewPartialProviderTrait;
27
28
    /**
29
     * Default view partial.
30
     *
31
     * @var string
32
     */
33
    private $defaultPartial = 'core/form/tree-add-item';
0 ignored issues
show
Unused Code introduced by
The property $defaultPartial is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
34
35
    public function init()
36
    {
37
        $this->setObject(new \ArrayObject);
38
        $this->add([
39
                'name' => 'id',
40
                'type' => 'Hidden',
41
            ]);
42
43
        $this->add([
44
                'name' => 'current',
45
                'type' => 'Hidden',
46
            ]);
47
        $this->add([
48
                'name' => 'do',
49
                'type' => 'Hidden',
50
            ]);
51
        $this->add([
52
                'name' => 'name',
53
                'type' => 'Text',
54
                'options' => [
55
                    'label' => /*@translate*/ 'Name',
56
                ],
57
58
                'attributes' => ['required' => 'required'],
59
            ]);
60
61
        $this->add([
62
                'name' => 'value',
63
                'type' => 'Text',
64
                'options' => [
65
                    'label' => /*@translate*/ 'Value',
66
                ],
67
            ]);
68
69
        $this->add([
70
                'name' => 'priority',
71
                'type' => 'Text',
72
            ]);
73
74
    }
75
76
    public function getInputFilterSpecification()
77
    {
78
        return [
79
            'name' => [
80
                'required' => true,
81
                'filters' => [
82
                    [ 'name' => 'StringTrim' ],
83
                ],
84
            ],
85
            'value' => [
86
                'required' => false,
87
                'filters' => [
88
                    [ 'name' => 'StringTrim' ],
89
                ],
90
            ],
91
        ];
92
    }
93
}