Time::renderScript()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 10
ccs 0
cts 8
cp 0
crap 6
rs 9.9332
c 0
b 0
f 0
1
<?php
2
namespace Rocket\UI\Forms\Fields;
3
4
/**
5
 * Manage date fields
6
 */
7
8
/**
9
 * Creates a date field with Form_element
10
 *
11
 * @author Stéphane Goetz
12
 */
13
class Time extends Field
14
{
15
    /**
16
     * Adds some specific attributes to be able to use the date picker automatically
17
     */
18
    protected function inputAttributes()
19
    {
20
        parent::inputAttributes();
21
22
        $this->input_attributes['type'] = 'text';
23
        $this->input_attributes['class'][] = 'time';
24
    }
25
26
    /**
27
     * Adds the script logic to the picker
28
     */
29
    protected function renderScript()
30
    {
31
        $options = ['format' => 'H:i'];
32
33
        if (array_key_exists('options', $this->params)) {
34
            $options = array_merge($this->params['options'], $options);
35
        }
36
37
        $this->getJS()->ready('$( "#' . $this->id . '").pickatime(' . json_encode($options) . ');');
38
    }
39
}
40