Skip to content

dynamikaweb/yii2-brasilapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dynamikaweb/yii2-brasilapi

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.