These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Encore\Admin\Form\Field; |
||
4 | |||
5 | class Date extends Text |
||
6 | { |
||
7 | protected static $css = [ |
||
8 | '/vendor/laravel-admin/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css', |
||
9 | ]; |
||
10 | |||
11 | protected static $js = [ |
||
12 | '/vendor/laravel-admin/moment/min/moment-with-locales.min.js', |
||
13 | '/vendor/laravel-admin/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js', |
||
14 | ]; |
||
15 | |||
16 | protected $format = 'YYYY-MM-DD'; |
||
17 | |||
18 | public function format($format) |
||
19 | { |
||
20 | $this->format = $format; |
||
21 | |||
22 | return $this; |
||
23 | } |
||
24 | |||
25 | public function prepare($value) |
||
26 | { |
||
27 | if ($value === '') { |
||
28 | $value = null; |
||
29 | } |
||
30 | |||
31 | return $value; |
||
32 | } |
||
33 | |||
34 | public function render() |
||
35 | { |
||
36 | $this->options['format'] = $this->format; |
||
37 | $this->options['locale'] = array_key_exists('locale', $this->options) ? $this->options['locale'] : config('app.locale'); |
||
38 | $this->options['allowInputToggle'] = true; |
||
39 | |||
40 | $this->script = "$('{$this->getElementClassSelector()}').parent().datetimepicker(".json_encode($this->options).');'; |
||
41 | |||
42 | $this->prepend('<i class="fa fa-calendar fa-fw"></i>') |
||
43 | ->defaultAttribute('style', 'width: 110px'); |
||
44 | |||
45 | return parent::render(); |
||
0 ignored issues
–
show
Bug
Compatibility
introduced
by
Loading history...
|
|||
46 | } |
||
47 | } |
||
48 |