yiibr / yii2-correios
通过邮政编码定位巴西地址
2.0.4
2016-12-22 17:27 UTC
Requires
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-09-20 22:43:17 UTC
README
此扩展允许自动完成和搜索巴西地址。
安装
将以下内容添加到您的 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() ?>