Home >Backend Development >PHP Tutorial >Automatic search using drop-down menu in yii2 framework yii-widget-select2 example analysis
The example in this article describes the method of automatically searching for yii-widget-select2 using the drop-down menu in the yii2 framework. Share it with everyone for your reference, the details are as follows:
Source code address in github: https://github.com/kartik-v/yii2-widget-select2
Use composer.phar to install this plug-in:
php composer .phar require kartik-v/yii2-widget-select2 "*"
Quotation method:
use kartikselect2Select2;
Source code:
<?= $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 ], ]); ?>
Detailed explanation of related content: http://demos. krajee.com/widget-details/select2
I hope this article will be helpful to everyone’s PHP program design based on the Yii framework.
The above introduces the analysis of the automatic search yii-widget-select2 using the drop-down menu in the yii2 framework, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.