kartik Select2 Yii2 如何允许选择输入的任何标签?
How in kartik Select2 Yii2 to allow choose any tag entered?
我需要保存标签的输入值,即使它不在可用数据库列表中。
<?php echo $form->field($model, 'tagsList')->label(false)->widget(Select2::className(), [
'data' => ArrayHelper::map(Tag::find()->all(), 'id', 'name'),
'options' => [
'multiple' => true,
'placeholder' => 'Choose tag ...',
'tags' => true
]
]); ?>
我找到了解决方案:
<?php echo $form->field($model, 'tagsList')->label(false)->widget(Select2::className(), [
'data' => ArrayHelper::map(Tag::find()->all(), 'id', 'name'),
'options' => [
'multiple' => true,
'placeholder' => 'Choose tag ...',
],
'pluginOptions' => [
'tags' => true
]
]); ?>
我需要保存标签的输入值,即使它不在可用数据库列表中。
<?php echo $form->field($model, 'tagsList')->label(false)->widget(Select2::className(), [
'data' => ArrayHelper::map(Tag::find()->all(), 'id', 'name'),
'options' => [
'multiple' => true,
'placeholder' => 'Choose tag ...',
'tags' => true
]
]); ?>
我找到了解决方案:
<?php echo $form->field($model, 'tagsList')->label(false)->widget(Select2::className(), [
'data' => ArrayHelper::map(Tag::find()->all(), 'id', 'name'),
'options' => [
'multiple' => true,
'placeholder' => 'Choose tag ...',
],
'pluginOptions' => [
'tags' => true
]
]); ?>