Completed
Push — develop ( 7c60f3...2c84c1 )
by
unknown
09:00
created

SearchFormFieldset::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 7
rs 9.4285
c 1
b 1
f 0
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license       MIT
8
 */
9
10
namespace Cv\Form;
11
12
use Zend\Form\Fieldset;
13
14
class SearchFormFieldset extends Fieldset
15
{
16
17
    protected $locationEngineType;
18
19
    public function __construct($name = null, $options = [])
20
    {
21
        parent::__construct($name, $options);
22
        if (array_key_exists('location_engine_type', $options)) {
23
            $this->locationEngineType = $options['location_engine_type'];
24
        }
25
    }
26
27
    public function init()
28
    {
29
        $this->setName('params');
30
        $this->add([
31
            'name' => 'search',
32
            'options' => [
33
                'label' => /*@translate*/ 'Search for resumes'
34
            ]
35
        ]);
36
37
        $this->add(
38
            [
39
                'name' => 'l',
40
                'type' => 'Location',
41
                'options' => [
42
                    'label' => /*@translate*/ 'Location',
43
                    'engine_type' => $this->locationEngineType,
44
                ],
45
            ]
46
        );
47
48
        $this->add(
49
            [
50
                'name' => 'd',
51
                'type' => 'Zend\Form\Element\Select',
52
                'options' => [
53
                    'label' => /*@translate*/ 'Distance',
54
                    'value_options' => [
55
                        '5' => '5 km',
56
                        '10' => '10 km',
57
                        '20' => '20 km',
58
                        '50' => '50 km',
59
                        '100' => '100 km'
60
                    ],
61
62
                ],
63
                'attributes' => [
64
                    'value' => '10', // default distance
65
                    'data-searchbox' => -1,  // hide the search box
66
                    'data-allowclear' => 'false', // allow to clear a selected value
67
                    'data-placeholder' => /*@translate*/ 'Distance',
68
                ]
69
            ]
70
        );
71
    }
72
}