Completed
Push — develop ( 965e31...31fe02 )
by
unknown
07:14
created

JobboardSearch::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 50
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 50
c 1
b 1
f 0
rs 9.3333
cc 1
eloc 35
nc 1
nop 0
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
/** ListFilterLocationFieldset.php */
11
namespace Jobs\Form;
12
13
use Core\Form\CustomizableFieldsetInterface;
14
use Core\Form\CustomizableFieldsetTrait;
15
use Core\Form\SearchForm;
16
use Jobs\Entity\Location;
17
18
/**
19
 * Adds the location search to the base search form.
20
 *
21
 * @package Jobs\Form
22
 */
23
class JobboardSearch extends SearchForm implements CustomizableFieldsetInterface
24
{
25
26
    use CustomizableFieldsetTrait;
27
28
    public function init()
29
    {
30
        $this->setAttribute('id','jobs-list-filter');
31
        $this->setOption('text_span', 5);
32
        parent::init();
33
        $this->setButtonElement('q');
34
35
        $this->add(
36
            [
37
                'name'       => 'l',
38
                'type'       => 'LocationSelect',
39
                'options'    => [
40
                    'label' => 'Location',
41
                    'span'  => 3,
42
                    'location_entity' => new Location(),
43
                ],
44
                'attributes' => [
45
                    'data-width' => '100%',
46
                ]
47
            ]
48
        );
49
        $this->setButtonElement('l');
50
51
52
        $this->add(
53
            array(
54
                'name'       => 'd',
55
                'type'       => 'Zend\Form\Element\Select',
56
                'options'    => array(
57
                    'label'         => /*@translate*/ 'Distance',
58
                    'value_options' => [
59
                        '5'   => '5 km',
60
                        '10'  => '10 km',
61
                        '20'  => '20 km',
62
                        '50'  => '50 km',
63
                        '100' => '100 km'
64
                    ],
65
                    'span'          => 4,
66
                ),
67
                'attributes' => [
68
                    'value'            => '10', // default distance
69
                    'data-searchbox'   => -1,  // hide the search box
70
                    'data-allowclear'  => 'false', // allow to clear a selected value
71
                    'data-placeholder' => /*@translate*/ 'Distance',
72
                    'data-width'       => '100%',
73
                ]
74
            )
75
        );
76
        $this->setButtonElement('d');
77
    }
78
}
79