MultipleInput Github
先安装 php composer.phar require unclead/yii2-multiple-input "~2.0"
...
<?= $form->field($model, 'pid')->widget(unclead\multipleinput\MultipleInput::class, [
'max' => 15,
'allowEmptyList'=>false,
'enableGuessTitle'=>true,
'columns'=> [[
'name' => 'pid',
'type' => \kartik\select2\Select2::class,
'title' => '标题ID',
'items' => [
'0' => 'Saturday',
'1' => 'Monday'
],
'options' => [
// 'prompt'=>['placeholder' => '请选择'],
'data' =>[
1 => "First", 2 => "Second", 3 => "Third",
4 => "Fourth", 5 => "Fifth",
],
],
// 'pluginOptions' => [
// 'allowClear' => true
// ],
],
]
])->label('多级文本');
?>
参数说明
select 2 单独使用
<?= $form->field($model, 'tag')->widget(kartik\select2\Select2::class, [
'data' => [
1 => "First", 2 => "Second", 3 => "Third",
4 => "Fourth", 5 => "Fifth"
],
'options' => ['placeholder' => '请选择'],
'pluginOptions' => [
'allowClear' => true
],
]);?>
编辑时候回显类型格式
Array
(
[0] => Array
(
[pid] => 3
)
[1] => Array
(
[pid] => 5
)
[2] => Array
(
[pid] => 4
)
[3] => Array
(
[pid] => 6
)
)