i14a45/yii2-custom-fields

Custom fields module for Yii 2

Installs: 10

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Forks: 0

Type:yii2-extension

dev-master 2021-05-13 14:33 UTC

This package is auto-updated.

Last update: 2024-04-13 20:39:16 UTC


README

Installation

The preferred way to install this extension is through composer.

composer require i14a45/yii2-custom-fields

Configuration

Database Migrations

./yii migrate --migrationPath=@vendor/i14a45/yii2-custom-fields/migrations

Module setup

To access the module, you need to add the following code to your application configuration:

return [
    //...
    'modules' => [
        //...
        'custom-fields' => [
            'class' => \i14a45\customfields\Module::class,
            'models' => [
                [
                    'class' => SampleModel::class,
                    'name' => 'Sample model',
                ],
            ],
        ],
    ],
];

>NOTE: Module id must be custom-fields and not otherwise

Behavior

use i14a45\customfields\behaviors\CustomFieldsBehavior;

class SampleModel extends \yii\db\ActiveRecord {

public function behaviors()
{
    return [
        'customFields' => [
            'class' => CustomFieldsBehavior::class,
        ]
    ];
}

}