|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Cv\Form; |
|
4
|
|
|
|
|
5
|
|
|
use Zend\Form\Fieldset; |
|
6
|
|
|
use Cv\Entity\Education as EducationEntity; |
|
7
|
|
|
use Core\Entity\Hydrator\EntityHydrator; |
|
8
|
|
|
use Zend\InputFilter\InputFilterProviderInterface; |
|
9
|
|
|
use Core\Form\ViewPartialProviderInterface; |
|
10
|
|
|
use Core\Form\ViewPartialProviderTrait; |
|
11
|
|
|
|
|
12
|
|
|
class EducationFieldset extends Fieldset implements InputFilterProviderInterface, ViewPartialProviderInterface |
|
13
|
|
|
{ |
|
14
|
|
|
|
|
15
|
|
|
use ViewPartialProviderTrait; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* View script for rendering |
|
19
|
|
|
* |
|
20
|
|
|
* @var string |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $defaultPartial = 'cv/form/education'; |
|
23
|
|
|
|
|
24
|
|
|
public function init() |
|
25
|
|
|
{ |
|
26
|
|
|
$this->setName('education') |
|
27
|
|
|
->setHydrator(new EntityHydrator()) |
|
28
|
|
|
->setObject(new EducationEntity()); |
|
29
|
|
|
|
|
30
|
|
|
$this->add( |
|
31
|
|
|
array( |
|
32
|
|
|
'type' => 'Core/Datepicker', |
|
33
|
|
|
'name' => 'startDate', |
|
34
|
|
|
'options' => array( |
|
35
|
|
|
'label' => /*@translate*/ 'Start date', |
|
36
|
|
|
'data-width' => '50%', |
|
37
|
|
|
'class' => 'selectpicker' |
|
38
|
|
|
) |
|
39
|
|
|
) |
|
40
|
|
|
); |
|
41
|
|
|
$this->add( |
|
42
|
|
|
array( |
|
43
|
|
|
'type' => 'Core/Datepicker', |
|
44
|
|
|
'name' => 'endDate', |
|
45
|
|
|
'options' => array( |
|
46
|
|
|
'label' => /*@translate*/ 'End date' |
|
47
|
|
|
) |
|
48
|
|
|
) |
|
49
|
|
|
); |
|
50
|
|
|
$this->add( |
|
51
|
|
|
array( |
|
52
|
|
|
'type' => 'checkbox', |
|
53
|
|
|
'name' => 'currentIndicator', |
|
54
|
|
|
'options' => array( |
|
55
|
|
|
'label' => /*@translate */ 'ongoing' |
|
56
|
|
|
) |
|
57
|
|
|
) |
|
58
|
|
|
); |
|
59
|
|
|
|
|
60
|
|
|
$this->add( |
|
61
|
|
|
array( |
|
62
|
|
|
'name' => 'competencyName', |
|
63
|
|
|
'options' => array( |
|
64
|
|
|
'label' => /*@translate */ 'Degree'), |
|
65
|
|
|
'attributes' => array( |
|
66
|
|
|
//'id' => 'education-competencyname', |
|
|
|
|
|
|
67
|
|
|
'title' => /*@translate */ 'please enter the name of your qualification' |
|
68
|
|
|
), |
|
69
|
|
|
) |
|
70
|
|
|
); |
|
71
|
|
|
|
|
72
|
|
|
$this->add( |
|
73
|
|
|
array( |
|
74
|
|
|
'name' => 'organizationName', |
|
75
|
|
|
'options' => array( |
|
76
|
|
|
'label' => /*@translate */ 'Organization Name'), |
|
77
|
|
|
'attributes' => array( |
|
78
|
|
|
//'id' => 'education-organizationname', |
|
|
|
|
|
|
79
|
|
|
'title' => /*@translate */ 'please enter the name of the university or school' |
|
80
|
|
|
), |
|
81
|
|
|
) |
|
82
|
|
|
); |
|
83
|
|
|
|
|
84
|
|
|
$this->add( |
|
85
|
|
|
array( |
|
86
|
|
|
'name' => 'country', |
|
87
|
|
|
'options' => array( |
|
88
|
|
|
'label' => /*@translate */ 'Country'), |
|
89
|
|
|
'attributes' => array( |
|
90
|
|
|
//'id' => 'education-country', |
|
|
|
|
|
|
91
|
|
|
'title' => /*@translate */ 'please select the country' |
|
92
|
|
|
), |
|
93
|
|
|
) |
|
94
|
|
|
); |
|
95
|
|
|
|
|
96
|
|
|
$this->add( |
|
97
|
|
|
array( |
|
98
|
|
|
'name' => 'city', |
|
99
|
|
|
'options' => array( |
|
100
|
|
|
'label' => /*@translate */ 'City'), |
|
101
|
|
|
'attributes' => array( |
|
102
|
|
|
//'id' => 'education-city', |
|
|
|
|
|
|
103
|
|
|
'title' => /*@translate */ 'please enter the name of the city' |
|
104
|
|
|
), |
|
105
|
|
|
) |
|
106
|
|
|
); |
|
107
|
|
|
|
|
108
|
|
|
$this->add( |
|
109
|
|
|
array( |
|
110
|
|
|
'name' => 'description', |
|
111
|
|
|
'type' => 'Zend\Form\Element\Textarea', |
|
112
|
|
|
'options' => array( |
|
113
|
|
|
'label' => /*@translate */ 'Description', |
|
114
|
|
|
), |
|
115
|
|
|
'attributes' => array( |
|
116
|
|
|
//'id' => 'education-description', |
|
|
|
|
|
|
117
|
|
|
'title' => /*@translate */ 'please enter a description', |
|
118
|
|
|
), |
|
119
|
|
|
) |
|
120
|
|
|
); |
|
121
|
|
|
|
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* |
|
126
|
|
|
* @see \Zend\InputFilter\InputFilterProviderInterface::getInputFilterSpecification() |
|
127
|
|
|
*/ |
|
128
|
|
|
public function getInputFilterSpecification() |
|
129
|
|
|
{ |
|
130
|
|
|
return [ |
|
131
|
|
|
'type' => 'Cv/Education' |
|
132
|
|
|
]; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* |
|
137
|
|
|
* @see \Zend\Form\Form::setData() |
|
138
|
|
|
*/ |
|
139
|
|
View Code Duplication |
public function populateValues($data) |
|
|
|
|
|
|
140
|
|
|
{ |
|
141
|
|
|
if (isset($data['currentIndicator']) |
|
142
|
|
|
&& isset($data['endDate']) |
|
143
|
|
|
&& $data['currentIndicator'] |
|
144
|
|
|
) { |
|
145
|
|
|
// empty & hide endDate if currentIndicator is checked |
|
146
|
|
|
$data['endDate'] = ''; |
|
147
|
|
|
$this->get('endDate')->setOption('rowClass', 'hidden'); |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
return parent::populateValues($data); |
|
151
|
|
|
} |
|
152
|
|
|
} |
|
153
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.