{"action":"closed","issue":{"url":"https://api.github.com/repos/BrendonKoz/CakePHP-Mcrypt-Behavior/issues/3","labels_url":"https://api.github.com/repos/BrendonKoz/CakePHP-Mcrypt-Behavior/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/BrendonKoz/CakePHP-Mcrypt-Behavior/issues/3/comments","events_url":"https://api.github.com/repos/BrendonKoz/CakePHP-Mcrypt-Behavior/issues/3/events","html_url":"https://github.com/BrendonKoz/CakePHP-Mcrypt-Behavior/issues/3","id":22729006,"number":3,"title":"Decrypt Associate Model","user":{"login":"aouchachacha","id":5947657,"avatar_url":"https://avatars.githubusercontent.com/u/5947657?v=3","gravatar_id":"","url":"https://api.github.com/users/aouchachacha","html_url":"https://github.com/aouchachacha","followers_url":"https://api.github.com/users/aouchachacha/followers","following_url":"https://api.github.com/users/aouchachacha/following{/other_user}","gists_url":"https://api.github.com/users/aouchachacha/gists{/gist_id}","starred_url":"https://api.github.com/users/aouchachacha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aouchachacha/subscriptions","organizations_url":"https://api.github.com/users/aouchachacha/orgs","repos_url":"https://api.github.com/users/aouchachacha/repos","events_url":"https://api.github.com/users/aouchachacha/events{/privacy}","received_events_url":"https://api.github.com/users/aouchachacha/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2013-11-15T12:15:55Z","updated_at":"2015-06-12T21:18:49Z","closed_at":"2015-06-12T21:18:49Z","body":"Hi,\r\n\r\nThanks a lot for your Behavior! I want to submit you an idea :\r\n\r\nIn your Model A add this line : \r\npublic $actsAs = array('Mcrypt' => array('fields' => array('ModelB.field1', 'ModelB.field2', 'ModelC.field1')));\r\n\r\nAnd then, in your Behavior, in the _decryptArray() function, if the $key isn't found in $this->config[$this->modelName]['fields'], test if $curModel.'.'.$key is in_array.\r\n\r\nHere is my code : \r\n\r\nif(in_array($key, $this->config[$this->modelName]['fields']) && $curModel == $this->modelName){\r\n    $values[$key] = $this->_decryptField($value);\r\n} else {\r\n    if(in_array($curModel.'.'.$key, $this->config[$this->modelName]['fields'])){\r\n        $values[$key] = $this->_decryptField($value);\r\n    }\r\n}\r\n\r\nI think it works fine. That's the case on my website.\r\n\r\nHappy coding!\r\n\r\nPS : i'm using it on cakePhp 2.3 and it works fine."}}