In a model, I have two fields that are arrays of values, those are imploded inside a model on beforeSave() and saved into database as strings (this is working fine).
Now, I need to know, how can I retrieve these two fields back into an array on afterFind() so the fields can be populated inside a form.
I should probably note that every form operation is done via RESTful API, and frontend is in AngularJS.
public $array_1 = [];
public $array_2 = [];
public function beforeSave($insert)
{
$this->array_1 = implode(',', $this->array_1);
$this->array_2 = implode(',', $this->array_2);
}
When I want to do an explode by the same principle, I get error that argument 2 in explode is expecting string and get's an array. I'm assuming that it's because of the array parameters declaration at the top of the file.
I'm total Yii2 newbie, so please be gentle. :)
array_1is already array when finding.