This Yii2 model behavior allows you to store arrays in attributes.
Run the Composer command to install the latest stable version:
composer require frostealth/yii2-array-field @stable
Just attach the behavior to your model.
use frostealth\yii2\behaviors\ArrayFieldBehavior;
public function behaviors()
{
return [
[
'class' => ArrayFieldBehavior::className(),
'attributes' => ['attribute1', 'attribute2'],
// 'defaultEncodedValue' => null,
// 'defaultDecodedValue' => [],
],
];
}
The MIT License (MIT). See LICENSE.md for more information.