2017 © Pedro PelΓ‘ez
 

yii2-extension cms-dadata-suggest

Π Π°Π±ΠΎΡ‚Π° с подсказками dadata.ru for SkeekS CMS

image

skeeks/cms-dadata-suggest

Π Π°Π±ΠΎΡ‚Π° с подсказками dadata.ru for SkeekS CMS

  • Tuesday, May 22, 2018
  • by skeeks-semenov
  • Repository
  • 1 Watchers
  • 0 Stars
  • 240 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 13 Versions
  • 3 % Grown

The README.md

Dadata suggest for SkeekS CMS

Info

  • https://github.com/skeeks-semenov/yii2-dadata-suggest-api
  • https://dadata.ru/api/suggest/

Installation

The preferred way to install this extension is through composer., (*1)

Either run, (*2)

php composer.phar require --prefer-dist skeeks/cms-dadata-suggest "*"

or add, (*3)

"skeeks/cms-dadata-suggest": "*"

Configuration app


'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', ] ]

Examples

First detect address from api and save to session

\Yii::$app->dadataSuggest->address

First detect address from api and save to session

if (\Yii::$app->dadataSuggest->isSavedAddress)
{
    echo \Yii::$app->dadataSuggest->address->unrestrictedValue;
} else
{
    echo "Not saved address to session";
}

Address widget

<?= \skeeks\cms\dadataSuggest\widgets\address\DadataGetAddressWidget::widget([
    'options' =>
    [
        'href' => '#',
        'onclick' => 'new sx.classes.ModalRegionPageReload(); return false;',
        'class' => 'sx-dadata-suggestion-city',
    ]
]); ?>

Suggest widget

= \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(
    [
        'class'         => 'form-control',
        'placeholder'   => 'Найти Π³ΠΎΡ€ΠΎΠ΄',
    ]
]); ?>

Suggest widgets in forms

= $form->field($model, 'post_recipient')->widget(
    \skeeks\cms\dadataSuggest\widgets\suggest\DadataSuggestInputWidget::className(),
    [
        'options' =>
        [
            'placeholder' => $model->getAttributeLabel('post_recipient'),
        ],

        'type' => 'NAME'
    ]
);
?>

### Suggest widgets with additional settings
```php

$form->field($model, 'post_address')->widget(
    \skeeks\cms\dadataSuggest\widgets\suggest\DadataSuggestInputWidget::className(),
    [
        'options' =>
        [
            'placeholder' => "АдрСс (ΡƒΠ»ΠΈΡ†Π°, Π΄ΠΎΠΌ, ΠΊΠ²)",
        ],

        'clientOptions' =>
        [
            'suggestOptions' =>
            [
                'triggerSelectOnSpace' => true,
                'triggerSelectOnBlur' => true,

                'constraints' => [
                    [
                        'locations' => \Yii::$app->dadataSuggest->address->getRegionArray(),

                        'deletable' => false,
                        'label'     => ''
                    ]
                ],
                'restrict_value' => true,
            ],
            'onInit' => new \yii\web\JsExpression(<<<JS
                function(e, data)
                {
                    data.DadataSuggest.bind('onSelect', function()
                    {
                        data.DadataSuggest.bind('afterSave', function()
                        {
                            $.pjax.reload({container:'#sx-cart-full'});
                        });

                        data.DadataSuggest.save();
                        return false;
                    });
                }
JS
            )

        ]
    ]);
?>

skeeks!
SkeekS CMS (Yii2) β€” fast, simple, effective!
skeeks.com | cms.skeeks.com, (*4)

The Versions

22/05 2018

dev-master

9999999-dev https://cms.skeeks.com/

Π Π°Π±ΠΎΡ‚Π° с подсказками dadata.ru for SkeekS CMS

  Sources   Download

BSD-3-Clause GPL-3.0+

The Requires

 

by Semenov Alexander

framework component yii suggest skeeks dadata

22/05 2018

1.1.3

1.1.3.0 https://cms.skeeks.com/

Π Π°Π±ΠΎΡ‚Π° с подсказками dadata.ru for SkeekS CMS

  Sources   Download

BSD-3-Clause

The Requires

 

by Semenov Alexander

framework component yii suggest skeeks dadata

12/11 2017

1.1.2

1.1.2.0 https://cms.skeeks.com/

Π Π°Π±ΠΎΡ‚Π° с подсказками dadata.ru for SkeekS CMS

  Sources   Download

GPL-3.0+

The Requires

 

by Semenov Alexander

framework component yii suggest skeeks dadata

12/11 2017

1.1.2.1

1.1.2.1 https://cms.skeeks.com/

Π Π°Π±ΠΎΡ‚Π° с подсказками dadata.ru for SkeekS CMS

  Sources   Download

GPL-3.0+

The Requires

 

by Semenov Alexander

framework component yii suggest skeeks dadata

12/11 2017

1.1.1

1.1.1.0 https://cms.skeeks.com/

Π Π°Π±ΠΎΡ‚Π° с подсказками dadata.ru for SkeekS CMS

  Sources   Download

GPL-3.0+

The Requires

 

by Semenov Alexander

framework component yii suggest skeeks dadata

07/11 2017

1.1.0

1.1.0.0 https://cms.skeeks.com/

Π Π°Π±ΠΎΡ‚Π° с подсказками dadata.ru for SkeekS CMS

  Sources   Download

GPL-3.0+

The Requires

 

by Semenov Alexander

framework component yii suggest skeeks dadata

07/11 2017

1.0.1.1

1.0.1.1 https://cms.skeeks.com/

Π Π°Π±ΠΎΡ‚Π° с подсказками dadata.ru for SkeekS CMS

  Sources   Download

GPL-3.0+

The Requires

 

by Semenov Alexander

framework component yii suggest skeeks dadata

06/11 2017

1.0.1

1.0.1.0 https://cms.skeeks.com/

Π Π°Π±ΠΎΡ‚Π° с подсказками dadata.ru for SkeekS CMS

  Sources   Download

GPL-3.0+

The Requires

 

by Semenov Alexander

framework component yii suggest skeeks dadata

23/10 2016

1.0.0-rc3

1.0.0.0-RC3 http://cms.skeeks.com/

Π Π°Π±ΠΎΡ‚Π° с подсказками dadata.ru for SkeekS CMS

  Sources   Download

GPL-3.0+

The Requires

 

by Semenov Alexander

framework component yii suggest skeeks dadata

11/10 2016

1.0.0-rc2

1.0.0.0-RC2 http://cms.skeeks.com/

Π Π°Π±ΠΎΡ‚Π° с подсказками dadata.ru for SkeekS CMS

  Sources   Download

GPL-3.0+

The Requires

 

by Semenov Alexander

framework component yii suggest skeeks dadata

27/09 2016

1.0.0-beta

1.0.0.0-beta http://cms.skeeks.com/

Π Π°Π±ΠΎΡ‚Π° с подсказками dadata.ru for SkeekS CMS

  Sources   Download

GPL-3.0+

The Requires

 

by Semenov Alexander

framework component yii suggest skeeks dadata

27/09 2016

1.0.0-rc1

1.0.0.0-RC1 http://cms.skeeks.com/

Π Π°Π±ΠΎΡ‚Π° с подсказками dadata.ru for SkeekS CMS

  Sources   Download

GPL-3.0+

The Requires

 

by Semenov Alexander

framework component yii suggest skeeks dadata

27/09 2016

1.0.0-alpha

1.0.0.0-alpha http://cms.skeeks.com/

Π Π°Π±ΠΎΡ‚Π° с подсказками dadata.ru for SkeekS CMS

  Sources   Download

GPL-3.0+

The Requires

 

by Semenov Alexander

framework component yii suggest skeeks dadata