Home > php教程 > php手册 > body text

yii2框架中使用下拉菜单的自动搜索yii-widget-select2实例分析,yii2widgetselect2

WBOY
Release: 2016-06-13 08:48:01
Original
1338 people have browsed it

yii2框架中使用下拉菜单的自动搜索yii-widget-select2实例分析,yii2widgetselect2

本文实例讲述了yii2框架中使用下拉菜单的自动搜索yii-widget-select2的方法。分享给大家供大家参考,具体如下:

github中源代码地址:https://github.com/kartik-v/yii2-widget-select2

利用composer.phar安装此插件:

php composer.phar require kartik-v/yii2-widget-select2 "*"

引用方法:

use kartik\select2\Select2;

源代码:

<&#63;= $form->field($model, 'companies_company_id')->widget(Select2::classname(), [
  'data' => ArrayHelper::map(Companies::find()->all(),'company_id','company_name'),
  'language' => 'en',
  'options' => ['placeholder' => 'Select a state ...'],
  'pluginOptions' => [
    'allowClear' => true
  ],
]); &#63;>

Copy after login

相关内容的详细解释:http://demos.krajee.com/widget-details/select2

希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。

您可能感兴趣的文章:

  • Yii2使用Bootbox插件实现自定义弹窗
  • 从零开始学YII2框架(四)扩展插件yii2-kartikgii
  • 从零开始学YII2框架(三)扩展插件yii2-gird
  • 从零开始学YII2框架(二)通过 Composer 安装扩展插件
  • yii2中使用Active Record模式的方法
  • YII2.0之Activeform表单组件用法实例
  • yii2中添加验证码的实现方法
  • Yii2框架引用bootstrap中日期插件yii2-date-picker的方法
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template