xtomdex / yii2-widget-country
使用Select2下拉小部件渲染国家列表
1.0.2
2019-11-28 03:15 UTC
Requires
- kartik-v/yii2-widget-select2: @dev
- lysenkobv/yii2-geoip: ~1.0
- xtomdex/country-flags: *
- yiisoft/yii2: >=2.0.0
This package is auto-updated.
Last update: 2024-09-28 14:22:40 UTC
README
此小部件扩展了Kartik的Select2小部件。它使用国家代码和名称作为数据,并在下拉列表中渲染列表。
安装
安装此扩展的首选方式是通过composer。
运行以下命令之一
php composer.phar require --prefer-dist xtomdex/yii2-widget-country "*"
或添加以下内容到您的composer.json文件的require部分。
"xtomdex/yii2-widget-country": "*"
使用方法
扩展安装后,只需在代码中使用它即可。
<?= \xtomdex\widgets\CountrySelect::widget([ 'preferredCountries' => ['UA', 'RU', 'BY'], //these countries will be at the top 'enableIpCountryFirst' => true, //sets user IP country to the top (preferred countries go next), by default is true 'displayFlags' => true, //displays country flag images next to their names, by default is true /* * Select2 config */ ]); ?>