Skip to content

fabristyle/yii2-correios

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yii2-correios

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

About

Yii2 Extension that provide CEP integration

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 65.9%
  • JavaScript 34.1%