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

AddItemFieldset::init()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 40
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 25
nc 1
nop 0
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
}