主题
Checkbox 组件
Element Plus Checkbox 多选框组件
基础用法
php
$form = new Form();
return $form->make(new Roles(), function (Form $form) {
$form->checkbox('status', '状态')->options([
[
'value' => 1,
'label' => '开启'
],
[
'value' => 0,
'label' => '关闭'
],
[
'value' => 2,
'label' => '隐藏'
]
]);
})->labelWidth(120);
默认值/赋值
php
$form = new Form();
return $form->make(new Roles(), function (Form $form) {
$form->checkbox('status', '状态')->options([
[
'value' => 1,
'label' => '开启'
],
[
'value' => 0,
'label' => '关闭'
],
[
'value' => 2,
'label' => '隐藏'
]
])->value([1,2]);
})->labelWidth(120);
禁用某个选项
php
$form = new Form();
return $form->make(new Roles(), function (Form $form) {
$form->checkbox('status', '状态')->options([
[
'value' => 1,
'label' => '开启'
],
[
'value' => 0,
'label' => '关闭',
'disabled' => true
],
[
'value' => 2,
'label' => '隐藏'
]
])->value([1,2]);
})->labelWidth(120);
按钮选项样式
php
$form = new Form();
return $form->make(new Roles(), function (Form $form) {
$form->checkbox('status', '状态')->options([
[
'value' => 1,
'label' => '开启'
],
[
'value' => 0,
'label' => '关闭',
'disabled' => true
],
[
'value' => 2,
'label' => '隐藏'
]
])->value([1,2])->asButton();
})->labelWidth(120);