PHP code example of skeeks / cms-dadata-suggest
1. Go to this page and download the library: Download skeeks/cms-dadata-suggest library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
skeeks / cms-dadata-suggest example snippets
'components' =>
[
'dadataSuggest' => [
'class' => 'skeeks\cms\dadataSuggest\CmsDadataSuggestComponent',
],
'dadataSuggestApi' => [
'class' => 'skeeks\cms\dadataSuggest\CmsDadataSuggestApi',
],
'i18n' => [
'translations' =>
[
'skeeks/dadata-suggest' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@skeeks/cms/dadataSuggest/messages',
'fileMap' => [
'skeeks/dadata-suggest' => 'main.php',
],
]
]
]
],
'modules' =>
[
'dadataSuggest' => [
'class' => 'skeeks\cms\dadataSuggest\CmsDadataSuggestModule',
]
]
\Yii::$app->dadataSuggest->address
if (\Yii::$app->dadataSuggest->isSavedAddress)
{
echo \Yii::$app->dadataSuggest->address->unrestrictedValue;
} else
{
echo "Not saved address to session";
}
<?= \skeeks\cms\dadataSuggest\widgets\address\DadataGetAddressWidget::widget([
'options' =>
[
'href' => '#',
'onclick' => 'new sx.classes.ModalRegionPageReload(); return false;',
'class' => 'sx-dadata-suggestion-city',
]
]);
<?= \skeeks\cms\dadataSuggest\widgets\suggest\DadataSuggestInputWidget::widget([
'name' => 'address',
'id' => 'sx-global-region-input',
'addon' => 'clear',
'value' => \Yii::$app->dadataSuggest->isSavedAddress ? \Yii::$app->dadataSuggest->address->unrestrictedValue : "",
'clientOptions' => [
'onInit' => new \yii\web\JsExpression(<<<JS
function(e, data)
{
data.DadataSuggest.bind('onSelect', function()
{
$("#sx-save-region").show();
});
}
JS
)
],
'options' =>
[
'class' => 'form-control',
'placeholder' => 'Найти город',
]
]);
<?= $form->field($model, 'post_recipient')->widget(
\skeeks\cms\dadataSuggest\widgets\suggest\DadataSuggestInputWidget::className(),
[
'options' =>
[
'placeholder' => $model->getAttributeLabel('post_recipient'),
],
'type' => 'NAME'
]
);
php composer.phar