承接 urichalex/yii2-dadata-widget 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

urichalex/yii2-dadata-widget

最新稳定版本:v1.0.1

Composer 安装命令:

composer require urichalex/yii2-dadata-widget

包简介

Yii2 Dadata Widget

README 文档

README

Widget for using hints of Dadata service.

Installation

1. Download

The preferred way to install this extension is through composer.

Run the following command:

$ composer require urichalex/yii2-dadata-widget

2. Get api key

Register at DaData.ru, 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:

'container' => [
    'definitions' => [
        \urichalex\yii2Dadata\DadataWidget::class => [
            'apiKey' => 'my-dadata-api-key',
        ],
    ],
],

Usage

use urichalex\yii2Dadata\DadataWidget;
<?= DadataWidget::widget([
    'model' => $model,
    'attribute' => 'inn',
    'apiKey' => 'your apiKey'
]) ?>

The following example will use the name property instead:

<?= DadataWidget::widget([
    'name' => 'inn',
    'apiKey' => 'your apiKey'
]) ?>

You can also use this widget in an yii\widgets\ActiveForm using the yii\widgets\ActiveField::widget() method, for example like this:

<?= $form->field($model, 'inn')->widget(DadataWidget::class, [
    'apiKey' => 'your apiKey'
]) ?>

You can also specify additional model attributes (or form field names) that will be filled in automatically. from the response from the service.

<?= $form->field($model, 'inn')->widget(DadataWidget::class, [
    'apiKey' => 'your apiKey',
    'customAttributes' => [
        // key - model attribute name or form field name, value - attribute from response from service
        'city' => 'city_with_type',
        
        // Value can be an array
        'house' => [
            'attribute' => 'house_with_type', // Dadata response attribute name (response.data.house_with_type)
            'selector' => '#my_input_id', // Form field selector to write the value to
            'createHiddenField' => true, // create hidden field
            'value' => $someValue, // set hidden field value
            'fieldOptions' => [ // some field html options
                'class' => 'myClassName',
                'data-attribute' => 'value'
            ]
        ],
    ],
]) ?>

Useful links

Testing

$ ./vendor/bin/phpunit

统计信息

  • 总下载量: 229
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固