QQ扫一扫联系
$detail->areaChina('field', '字段名');
$detail->audio('field', '字段名');
$detail->captcha('field', '字段名');
$detail->checkbox('field', '名称');
$detail->code('field', '名称');
$detail->color('field', '字段名');
$detail->currency('field', '字段名');
$detail->date('field', '字段名');
$detail->datetime('field', '字段名');
$field = $detail->decimal('field', '字段名');
// 是否显示颜色(正数绿色,负数红色)
$field->autoColor(true);
// 是否总是显示正负号
$field->signShow(true);
$detail->display('field','名称');
$detail->file('field', '字段名');
临时路径指上传到临时表 data_temp 中的图片,正式保存时会将临时图片移动到正式表 data 中。
$detail->fileTemp('field', '字段名');
$detail->files('field', '字段名');
$detail->hidden('field', '字段名');
$detail->html('field', '字段名');
$detail->icon('field', '字段名');
$detail->id('field', '字段名');
$detail->image('field', '字段名');
$detail->images('field', '字段名');
临时路径指上传到临时表 data_temp 中的图片,正式保存时会将临时图片移动到正式表 data 中。
$detail->imagesTemp('field', '字段名');
字段存储的是 JSON 格式的 ID 列表,通过 ID 列表获取对应的条目名称
$detail->jsonIdItems('field', '字段名');
// 条目选择接口
->selectUrl(modstart_admin_url('path/to/select'))
// 指定预览接口
->previewUrl(modstart_admin_url('path/to/preview'))
// 指定条目样式,ITEM_STYLE_TITLE、ITEM_STYLE_COVER_TITLE
->itemStyle(JsonIdItems::ITEM_STYLE_TITLE);
条目选择接口需要返回
{
"code": 0,
"data": {
"records": [
{"id": 1, "title": "选项1", "cover": "http://xxx.com/xxx.jpg"},
{"id": 2, "title": "选项2", "cover": "http://xxx.com/xxx.jpg"}
]
}
}
条目预览接口接收 ids 参数,该参数使用 , 分隔的多个ID,返回的数据格式如下
{
"code": 0,
"data": {
"records": [
{"id": 1, "title": "选项1", "cover": "http://xxx.com/xxx.jpg"},
{"id": 2, "title": "选项2", "cover": "http://xxx.com/xxx.jpg"}
]
}
}
$detail->keyValueList('field', '字段名');
$detail->link('field', '字段名');
$detail->markdown('field', '字段名');
$detail->multiSelect('field', '字段名')->options([
'a' => '选项1',
'b' => '选项2',
'c' => '选项3',
]);
$field = $detail->number('field', '字段名');
// 是否显示颜色(正数绿色,负数红色)
$field->autoColor(true);
// 是否总是显示正负号
$field->signShow(true);
$detail->password('field', '字段名');
$detail->percent('field', '字段名');
$detail->radio('field', '字段名');
$detail->richHtml('field', '字段名');
// 基本使用
$field = $detail->select('field', '字段名');
// 使用Type作为备选项,XxxType是继承BaseType的类
$field->optionType(XxxType::class);
// 使用数组作为备选项
$field->options(['1' => '选项1', '2' => '选项2']);
// 使用数组作为备选项
$field->optionArray([['id' => 1, 'name' => '选项1'], ['id' => 2, 'name' => '选项2']],'id','name');
// 使用模型作为备选项
$field->optionModel('forum_category','id','title');
// 使用模型作为备选项(简单条件筛选)
$field->optionModel('forum_category','id','title',['xxx'=>'xxx']);
// 使用模型作为备选项,并渲染为树状结构
$detail->select('position', '位置')->optionModelTree('forum_category','id','title');
$detail->selectRemote('seriesId', '剧集')
// 指定远程数据源
->server(modstart_admin_url('path/to/select_remote'))
// 显示时查找的数据字段
->viewWithModel(XxxModel::class,'id','title');
远程数据源接口需要返回
{
"code": 0,
"data": {
"options": [
{"value": 1, "label": "选项1"},
{"value": 2, "label": "选项2"}
]
}
}
系统封装好了参数可以直接试用,远程数据源可以直接调用以下方法返回
class XxxController extends Controller
{
public function selectRemote()
{
return SelectRemote::handleModel(XxxModel::class,'id','title');
}
}
$detail->switch('field', '字段名');
$detail->tags('field', '名称');
$detail->text('field', '名称');
$detail->textarea('field', '字段名');
$detail->time('field', '字段名');
$detail->tree('field', '名称');
// 基础使用
$field = $detail->type('field', '字段名');
// 定义BaseType,同时指定类型颜色
$field->type(XxxStatus::class, [
XxxStatus::SUCCESS => 'success',
XxxStatus::FAIL => 'danger',
])
$detail->values('field', '字段名');
$detail->video('field', '字段名');
更多内置组件请参照 ModStart\Support\Manager\FieldManager 中的定义