Components for working with Dadata, (*1)
, (*2)
DaData API, (*3)
Installation
The preferred way to install this extension is through composer.
Either run, (*4)
php composer.phar require --prefer-dist mrssoft/yii2-dadata "*"
or add, (*5)
"mrssoft/yii2-dadata": "*"
to the require section of your composer.json
file., (*6)
Usage
echo DaDataInputWidget::widget([
'name' => 'name',
'options' => [
'class' => 'form-control',
'placeholder' => 'you placeholder'
],
'clientOptions' => [
'token' => 'you token',
'count' => 5,
'type' => DaDataInputWidget::TYPE_PARTY,
],
'clientEvents' => [
'onSelect' => new \yii\web\JsExpression('function (suggestion) {
console.log(suggestion);
}')
]
]);
$ipLocate = new DaDataIpLocate(['token' => '...']);
$response = $ipLocate->address();
//or
$response = $ipLocate->address($ip);