northug / yii2-simplelist
Список данных для аттрибута модели
dev-master
2019-04-09 10:42 UTC
Requires
- yiisoft/yii2: ~2.0
Requires (Dev)
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2025-03-10 01:25:10 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'],
],
]) ?>