self::TYPE_TEXT ]; /** * @var array */ protected static $propsRule = [ 'type' => 'string', 'size' => 'string', 'placeholder' => 'string', 'clearable' => 'boolean', 'disabled' => 'boolean', 'readonly' => 'boolean', 'maxlength' => 'int', 'icon' => 'string', 'rows' => 'int', 'number' => 'boolean', 'autofocus' => 'boolean', 'autocomplete' => 'boolean', 'spellcheck' => 'boolean', 'wrap' => 'string', ]; /** * */ protected function init() { $this->placeholder($this->getPlaceHolder()); } protected function getPlaceHolder($pre = '请输入') { return parent::getPlaceHolder($pre); } public function getValidateHandler() { return Validate::str(Validate::TRIGGER_BLUR); } /** * 自适应内容高度,仅在 textarea 类型下有效 * * @param Bool|Number $minRows * @param null|Number $maxRows * @return $this */ public function autoSize($minRows = false, $maxRows = null) { $this->props['autosize'] = $maxRows === null ? boolval($minRows) : compact('minRows', 'maxRows'); return $this; } /** * 生成表单规则 * * @return array */ public function build() { return [ 'type' => $this->name, 'field' => $this->field, 'title' => $this->title, 'value' => $this->value, 'props' => (object)$this->props, 'validate' => $this->validate, 'col' => $this->col ]; } }