组件说明
邮箱输入组件用于输入和验证邮箱地址。
用法示例
use plugin\xbCode\builder\Builder;
use plugin\xbCode\builder\Renders\Form;
Builder::form(function (Form $builder) {
// 基础用法
$builder->addRowEmailInput('email', '邮箱地址', '', function($component) {
$component->placeholder('请输入邮箱地址');
$component->required(true);
$component->clearable(true);
});
// 带验证规则
$builder->addRowEmailInput('work_email', '工作邮箱', '', [
'required' => true,
'validations' => [
'isEmail' => true
],
'validationErrors' => [
'isEmail' => '请输入正确的邮箱地址'
]
]);
});
组件参数
| 参数名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| name | string | - | 字段名称 |
| label | string | - | 字段标签 |
| value | string | - | 默认值 |
| placeholder | string | - | 占位文本 |
| clearable | bool | false | 是否可清除 |
| required | bool | false | 是否必填 |
| disabled | bool | false | 是否禁用 |
| maxLength | int | - | 最大长度 |
| validations | array | - | 验证规则 |
| validationErrors | array | - | 验证错误信息 |
使用说明
- 组件自动进行邮箱格式验证
- 支持标准的input-text所有特性
- 建议配合validations使用以提供更详细的错误提示