该 set 检查器类型 用于从预定义选项中进行多项选择。 该 set 检查器类型支持定义选项的相同方法 作为 dropdown 检查器类型。
public function defineProperties()
{
return [
'units' => [
'title' => 'Select Muitple Units',
'type' => 'set',
'items' => [
'metric' => 'Metric',
'imperial' => 'Imperial'
]
]
];
}生成的输出是一个数组值,对应于所选选项,例如:
"units": ["metric", "imperial"]以下 配置值 常用且受支持。
| Property | Description |
|---|---|
| title | title for the property. |
| description | a brief description of the property, optional. |
| items | an array of available items as keys and values, optional if defining a get*PropertyName*Options method. |
| default | an array of selected items by default containing keys only. |
default 参数,如果指定,应是一个数组,列出默认选定的项目键。
public function defineProperties()
{
return [
'context' => [
'title' => 'Context',
'type' => 'set',
'items' => [
'create' => 'Create',
'update' => 'Update',
'preview' => 'Preview'
],
'default' => ['create', 'update']
]
];
}该指定该 items 动态地,使用创建一个方法名为 get*PropertyName*Options 定义在该模型中。
public function getContextOptions()
{
return ContextModel::pluck('name', 'code')->all();
}