| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace Dcat\Admin\Form\Field;
- class Date extends Text
- {
- public static $js = [
- '@moment',
- '@bootstrap-datetimepicker',
- ];
- public static $css = [
- '@bootstrap-datetimepicker',
- ];
- protected $format = 'YYYY-MM-DD';
- public function format($format)
- {
- $this->format = $format;
- return $this;
- }
- protected function prepareInputValue($value)
- {
- if ($value === '') {
- $value = null;
- }
- return $value;
- }
- public function render()
- {
- $this->options['format'] = $this->format;
- $this->options['locale'] = config('app.locale');
- $this->options['allowInputToggle'] = true;
- $this->script = "$('{$this->getElementClassSelector()}').datetimepicker(".admin_javascript_json($this->options).');';
- $this->prepend('<i class="fa fa-calendar fa-fw"></i>')
- ->defaultAttribute('style', 'width: 200px;flex:none');
- return parent::render();
- }
- }
|