Completed
Pull Request — develop (#236)
by ANTHONIUS
09:12
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*/
34
                    'Desired work'
35
            ]
36
        ]);
37
38
        $this->add(
39
            array(
40
                'name' => 'l',
41
                'type' => 'Location',
42
                'options' => array(
43
                    'label' => /*@translate*/
44
                        'Location',
45
                    'engine_type' => $this->locationEngineType,
46
                ),
47
            )
48
        );
49
50
        $this->add(
51
            array(
52
                'name' => 'd',
53
                'type' => 'Zend\Form\Element\Select',
54
                'options' => array(
55
                    'label' => /*@translate*/
56
                        'Distance',
57
                    'value_options' => [
58
                        '5' => '5 km',
59
                        '10' => '10 km',
60
                        '20' => '20 km',
61
                        '50' => '50 km',
62
                        '100' => '100 km'
63
                    ],
64
65
                ),
66
                'attributes' => [
67
                    'value' => '10', // default distance
68
                    'data-searchbox' => -1,  // hide the search box
69
                    'data-allowclear' => 'false', // allow to clear a selected value
70
                    'data-placeholder' => /*@translate*/
71
                        'Distance',
72
                ]
73
            )
74
        );
75
    }
76
}