This library has the functionality to consume data from BrasilAPI, and process this data in the form of widgets. See full API documentation
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.
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'
],
]
this widget will consume the data obtained by the api and distribute it in the fields informed in the options.
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',
]
]);
This project is under BSD-3-Clause license.