northug/yii2-simplelist

Список данных для аттрибута модели

Installs: 177

Dependents: 0

Suggesters: 0

Security: 0

Type:yii2-extension

dev-master 2019-04-09 10:42 UTC

This package is auto-updated.

Last update: 2024-04-09 23:21:21 UTC


README

Add Meta Tags and Title in model

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist northug/yii2-simplelist "*"

or add

"northug/yii2-simplelist": "*"

to the require section of your composer.json file.

Migrate:

yii migrate --migrationPath=@northug/metaTags/migrations

Usage

Once the extension is installed, simply use it in your code by :

Add MetaTagBehavior to your model, and configure it.

'controllerMap' => [
    ...
    'simplelist' => [
        'class' => 'northug\simplelist\Controller',
    ]
    ...
],

In model

public function behaviors() {
    return [
        [
            'class' => ListBehavior::class,
            'attributes' => ['attribute'],
        ],
    ];
}

In form

<?= $form->field($model, 'attribute')->widget(ListWidget::class, [
        'structure' => [
            ['name' => 'code', 'title' => 'Code city', 'type' => 'text'],
            ['name' => 'phone', 'title' => 'Phone city', 'type' => 'text'],
        ],
    ]) ?>