dynamikaweb/yii2-brasilapi

yii2 widget for zip code queries from Brazil, using BrasilApi resources

Installs: 252

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Type:yii2-extension

v1.0.1 2021-07-05 18:55 UTC

This package is auto-updated.

Last update: 2024-10-13 19:01:35 UTC


README

php version pkg version license quality build

Description

This library has the functionality to consume data from BrasilAPI, and process this data in the form of widgets. See full API documentation

Installation

The preferred way to install this extension is through composer.

Either run

$ composer require dynamikaweb/yii2-brasilapi "*"

or add

"dynamikaweb/yii2-brasilapi": "*"

to the require section of your composer.json file.

Usage

add the rule to your urlManager component and also add modules

    'components' =>[
        'urlManager' => [
            ...
            'rules' => [
                'brasilapi/<route:[a-zA-Z0-9\/-]+>' => 'brasilapi/request/index',
            ]
        ]
    ],
    ...
    'modules' => [
        'brasilapi' =>  [
            'class' => '\dynamikaweb\brasilapi\Module'
        ],
    ]

Widgets

this widget will consume the data obtained by the api and distribute it in the fields informed in the options.


Widget Cep

Remembering that the corresponding IDs must be added to fill in correctly. If you are using MaterializeCSS add the option 'template' => CepWidget::TEMPLATE_MATERIALIZE.

use dynamikaweb\brasilapi\widgets\CepWidget;
...
echo $form->field($model, 'cep')->widget(CepWidget::className(), [
    //'template' => CepWidget::TEMPLATE_MATERIALIZE,
    'fields' => [
        'street' => 'id-model-street',
        'neighborhood' => 'id-model-neighborhood',
        'city' => 'id-model-city',
        'state' => 'id-model-state',
    ]
]);

or

echo CepWidget::widget([
    'fields' => [
        'street' => 'id-model-street',
        'neighborhood' => 'id-model-neighborhood',
        'city' => 'id-model-city',
        'state' => 'id-model-state',
    ]
]);

dynamika soluções web This project is under BSD-3-Clause license.