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

63 lines
1.3 KiB
PHP

<?php
namespace admin\components\UI\Form;
/**
* Class Textarea
* 多行输入框
* @package backend\components\UI\Form
*/
class Textarea extends Element implements Component
{
protected int $limit = 0;
/**
* 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 $num
* @return $this
*/
public function limit($num): self
{
$this->limit = $num;
return $this;
}
/**
* @return array
*/
public function render(): array
{
$data = [
'nodeName' => 'a-textarea',
'vModel:modelValue' => $this->getModelField(),
'placeholder' => $this->attr['placeholder'] ?: '请输入' . $this->name,
'allowClear' => true,
'showWordLimit' => true
];
if ($this->limit) {
$data['maxLength'] = $this->limit;
}
if($this->replace != ''){
$data['vStringReplace'] = $this->replace;
}
return $data;
}
}