An example of this article describes the method of automatic search yii-widget-select2 using Pull-down menus in the YII2 framework. Share to everyone for your reference, specific as follows:
Source code address in GitHub: Https://github.com/kartik-v/yii2-widget-select2
Install this plugin with Composer.phar:
PHP Composer.phar require kartik-v/yii2-widget-select2 "*"
Reference method:
Use Kartik\select2\select2;
Source:
<?= $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 help you with the PHP program design based on the YII framework.