yiibr/yii2-correios

通过邮政编码定位巴西地址

安装次数: 12,709

依赖者: 0

推荐者: 0

安全: 0

星标: 12

关注者: 7

分支: 9

开放问题: 2

类型:yii2-extension

2.0.4 2016-12-22 17:27 UTC

This package is not auto-updated.

Last update: 2024-09-20 22:43:17 UTC


README

此扩展允许自动完成和搜索巴西地址。

Yii2 Latest Stable Version Code Climate Total Downloads

安装

将以下内容添加到您的 composer.json 文件的 require 部分

"yiibr/yii2-correios": "*"

配置

在您的控制器中。

public function actions()
{
    return [
        ...
        'addressSearch' => 'yiibr\correios\CepAction'
        ...
    ];
}

如何使用

在您的视图文件中。

<?php
use yiibr\correios\CepInput;
?>

...

<?= CepInput::widget([
    'name' => 'cep',
    'action' => ['addressSearch'],
    'fields' => [
        'location' => 'location_input_id',
        'district' => 'district_input_id',
        'city' => 'city_input_id',
        'state' => 'state_input_id'
    ],
]); ?>
// Example:

<?= $form->field($model, 'cep',)->widget('yiibr\correios\CepInput', [
    'action' => ['addressSearch'],
    'fields' => [
        'location' => 'address-location',
        'district' => 'address-district',
        'city' => 'address-city',
        'state' => 'address-state',
    ],
]) ?>

<?= $form->field($model, 'location')->textInput() ?>
<?= $form->field($model, 'district')->textInput() ?>
<?= $form->field($model, 'city')->textInput() ?>
<?= $form->field($model, 'state')->textInput() ?>