xtomdex/yii2-widget-country

使用Select2下拉小部件渲染国家列表

安装次数: 101

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:yii2-extension

1.0.2 2019-11-28 03:15 UTC

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
     */
]); ?>