aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/forms/DatetimepickerInput.php
blob: 1f1f212230d9119b8c0e51bf85a17ec40934d934 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

namespace Studip\Forms;

class DatetimepickerInput extends Input
{
    public function render()
    {
        $attributes = "";
        foreach ((array) $this->attributes as $key => $value) {
            if (in_array($key, ['mindate', 'maxdate'])) {
                $key = ":".$key;
            }
            $attributes .= " ".$key.'="'.htmlReady($value).'"';
        }
        $template = $GLOBALS['template_factory']->open('forms/datetimepicker_input');
        $template->title = $this->title;
        $template->name = $this->name;
        $template->value = $this->getValue();
        $template->id = md5(uniqid());
        $template->required = $this->required;
        $template->attributes = $attributes;
        return $template->render();
    }

    /**
     * Turns an empty string into null value.
     * @return integer|null
     */
    public function dataMapper($value)
    {
        return $value ?: null;
    }
}