Save array to json with getter

Hi all,

With CakePHP 3, i’m trying to save Array to json with setter, but i always get empty value.

My form inputs :


My Setter :

function _setTag($tag) {
    // debug($tag); <- Return always empty value
    return json_encode($tag);

Someone can help me ?

Thanks !

You can’t use setters/getters on you entity for this. You need complex types:

You’ll add something like this to your table:

Type::map('json', 'Cake\Database\Type\JsonType');