How to store array values in Yii model property

In some scenarios, we require to store multiple values in your class attribute of your Yii model. We usually use this for showing check boxes or multiple select in your Yii form.

Add new Rule for your field “arrayField” in your model:

Overwrite your model’s “savemethod and change the array value as serialized string to store this in your database table.