petrabarus/yii2-googleplacesautocomplete

Google Places Auto Complete input widget for Yii2

dev-master 2015-10-26 06:11 UTC

This package is auto-updated.

Last update: 2024-11-22 16:22:44 UTC


README

Google Places Auto Complete widget for Yii2

##Installation

Add below to your composer.json file

    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/petrabarus/yii2-googleplacesautocomplete"
        }
    ],
    "requires": {
        "petrabarus/yii2-googleplacesautocomplete": "*"
    }

##Usage

Using widget and model.

use PetraBarus\Yii2\GooglePlacesAutoComplete\GooglePlacesAutoComplete;

echo GooglePlacesAutoComplete::widget([
    'model' => $model,
    'attribute' => 'location'
]);

Using widget for custom field name and value.

use PetraBarus\Yii2\GooglePlacesAutoComplete\GooglePlacesAutoComplete;
echo GooglePlacesAutoComplete::widget([
    'name' => 'place'
    'value' => 'Jakarta'
]);

Using active form.

use yii\bootstrap\ActiveForm;
use PetraBarus\Yii2\GooglePlacesAutoComplete\GooglePlacesAutoComplete;

echo $form = ActiveForm::begin();
echo $form->field($model, 'location')->widget(GooglePlacesAutoComplete::className());