QQ扫一扫联系
$builder->areaChina('field', '类型');
$builder->audio('field', '类型');
$builder->captcha('field', '类型');
$builder->checkbox('field', '名称');
$builder->code('field', '名称');
$builder->color('field', '类型');
$builder->currency('field', '类型');
$builder->date('field', '类型');
$builder->datetime('field', '类型');
$builder->decimal('field', '类型');
$builder->display('field','名称');
$builder->file('field', '类型');
$builder->fileTemp('field', '类型');
$builder->hidden('field', '类型');
$builder->html('field', '类型');
$builder->icon('field', '类型');
$builder->id('field', '类型');
$builder->image('field', '类型');
$builder->type('field', '类型');
$builder->type('field', '类型');
字段存储的是 JSON 格式的 ID 列表,通过 ID 列表获取对应的条目名称
$grid->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"}
]
}
}
$builder->keyValueList('field', '类型');
$builder->link('field', '类型');
$builder->markdown('field', '类型');
$builder->multiSelect('field', '字段名')->options([
'a' => '选项1',
'b' => '选项2',
'c' => '选项3',
]);
$builder->number('field', '类型');
$builder->password('field', '类型');
$builder->percent('field', '类型');
$builder->radio('field', '类型');
$builder->richHtml('field', '类型');
$field = $builder->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']);
// 使用模型作为备选项,并渲染为树状结构
$field->optionModelTree('forum_category','id','title');
$builder->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');
}
}
$builder->switch('field', '类型');
$builder->tags('field', '名称');
$builder->text('field', '名称');
$builder->textarea('field', '类型');
$builder->time('field', '类型');
$builder->tree('field', '名称');
$builder->type('field', '类型');
$builder->values('field', '类型');
$builder->video('field', '类型');
更多内置组件请参照 ModStart\Support\Manager\FieldManager
中的定义