yiibr/yii2-correios

Locates an address in Brazil by postal code

Installs: 13 094

Dependents: 0

Suggesters: 0

Security: 0

Stars: 12

Watchers: 7

Forks: 9

Open Issues: 2

Type:yii2-extension

2.0.4 2016-12-22 17:27 UTC

This package is not auto-updated.

Last update: 2024-11-15 23:25:29 UTC


README

This extension allows automatic completion and search Brazilian address.

Yii2 Latest Stable Version Code Climate Total Downloads

Installation

Add to the require section of your composer.json file:

"yiibr/yii2-correios": "*"

Configuration

On your controller.

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

How to use

On your view file.

<?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() ?>