Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/corpsepk/yii2-dadata-suggestions-widget
Yii2 wrapper for DaData's jQuery plugin
https://github.com/corpsepk/yii2-dadata-suggestions-widget
dadata yii2 yii2-extension
Last synced: about 2 months ago
JSON representation
Yii2 wrapper for DaData's jQuery plugin
- Host: GitHub
- URL: https://github.com/corpsepk/yii2-dadata-suggestions-widget
- Owner: corpsepk
- License: mit
- Created: 2017-03-02T12:33:39.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-25T09:26:51.000Z (about 6 years ago)
- Last Synced: 2024-11-02T08:51:36.808Z (about 2 months ago)
- Topics: dadata, yii2, yii2-extension
- Language: PHP
- Homepage:
- Size: 33.2 KB
- Stars: 10
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yii2-dadata-suggestions-widget
[![Latest Version](https://img.shields.io/github/tag/corpsepk/yii2-dadata-suggestions-widget.svg?style=flat-square&label=release)](https://github.com/corpsepk/yii2-dadata-suggestions-widget/tags)
[![Build Status](https://img.shields.io/travis/corpsepk/yii2-dadata-suggestions-widget/master.svg?style=flat-square)](https://travis-ci.org/corpsepk/yii2-dadata-suggestions-widget)
[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/corpsepk/yii2-dadata-suggestions-widget.svg?style=flat-square)](https://scrutinizer-ci.com/g/corpsepk/yii2-dadata-suggestions-widget/code-structure)
[![Quality Score](https://img.shields.io/scrutinizer/g/corpsepk/yii2-dadata-suggestions-widget.svg?style=flat-square)](https://scrutinizer-ci.com/g/corpsepk/yii2-dadata-suggestions-widget)Wrapper for [DaData](https://dadata.ru/suggestions/)'s jQuery plugin
## Installation
### 1. Download
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).Run the following command:
```bash
$ composer require corpsepk/yii2-dadata-suggestions-widget:~0.4
```### 2. Get api key
Register at [DaData.ru](https://dadata.ru/profile/#info), and get api key.### 3. Configure (optional)
You can setup container definitions if you do not want to enter api key in every widget.
Add following lines to your main configuration file:```php
'container' => [
'definitions' => [
'corpsepk\DaData\SuggestionsWidget' => [
'token' => 'my-dadata-api-key',
],
],
],
```## Usage
```php
use corpsepk\DaData\SuggestionsWidget;
``````php
= SuggestionsWidget::widget([
'model' => $model,
'attribute' => 'inn',
'token' => 'your apiKey'
]) ?>
```
The following example will use the name property instead:
```php
= SuggestionsWidget::widget([
'name' => 'inn',
'token' => 'your apiKey'
]) ?>
```
You can also use this widget in an `yii\widgets\ActiveForm` using the `yii\widgets\ActiveField::widget()`
method, for example like this:
```php
= $form->field($model, 'inn')->widget(SuggestionsWidget::class, [
'token' => 'your apiKey'
]) ?>
```## Useful links
- DaData - https://dadata.ru
- jQuery plugin - https://github.com/hflabs/suggestions-jquery
- jQuery plugin options - https://confluence.hflabs.ru/pages/viewpage.action?pageId=204669097
- Hints - https://dadata.userecho.com/topics/2090## Testing
```bash
$ ./vendor/bin/phpunit
```