Files
xk-api-yii/admin/components/UI/Form/Time.php
2024-09-19 11:32:39 +08:00

54 lines
1.1 KiB
PHP

<?php
namespace admin\components\UI\Form;
/**
* Class Time
* 时间选择器
* @package backend\components\UI\Form
*/
class Time extends Element implements Component
{
protected string $string = 'HH:mm:ss';
/**
* Text constructor.
* @param string $name
* @param string $field
* @param string $has
*/
public function __construct(string $name, string $field, string $has = '')
{
$this->name = $name;
$this->field = $field;
$this->has = $has;
$this->attr['placeholder'] = null;
}
/**
* 时间格式
* @param string $format
* @return $this
*/
public function string(string $format): self
{
$this->string = $format;
return $this;
}
/**
* @return array
*/
public function render(): array
{
return [
'nodeName' => 'a-time-picker',
'allowClear' => true,
'format' => $this->string,
'placeholder' => $this->attr['placeholder'] ?: '请选择' . $this->name,
'vModel:model-value' => $this->getModelField()
];
}
}