xtomdex/yii2-widget-country

Rendering countries list with Select2 dropdown widget

Installs: 101

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

1.0.2 2019-11-28 03:15 UTC

This package is auto-updated.

Last update: 2024-03-28 13:16:13 UTC


README

This widget extends Kartik's Select2 widget. It uses country codes and names as data and renders list in dropdown.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist xtomdex/yii2-widget-country "*"

or add

"xtomdex/yii2-widget-country": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

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