{"action":"opened","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/11153","repository_url":"https://api.github.com/repos/yiisoft/yii2","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/11153/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/11153/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/11153/events","html_url":"https://github.com/yiisoft/yii2/issues/11153","id":142202222,"number":11153,"title":"Can't set unsafe attribute in default scenario with custom validator","user":{"login":"conick","id":4551588,"avatar_url":"https://avatars.githubusercontent.com/u/4551588?v=3","gravatar_id":"","url":"https://api.github.com/users/conick","html_url":"https://github.com/conick","followers_url":"https://api.github.com/users/conick/followers","following_url":"https://api.github.com/users/conick/following{/other_user}","gists_url":"https://api.github.com/users/conick/gists{/gist_id}","starred_url":"https://api.github.com/users/conick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conick/subscriptions","organizations_url":"https://api.github.com/users/conick/orgs","repos_url":"https://api.github.com/users/conick/repos","events_url":"https://api.github.com/users/conick/events{/privacy}","received_events_url":"https://api.github.com/users/conick/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-20T20:34:46Z","updated_at":"2016-03-20T20:34:46Z","closed_at":null,"body":"Is there is a simply way to use unsafe attribute with custom validator which every time executes?\r\n\r\n```\r\npublic function rules()\r\n{\r\n\treturn [\r\n\t\t['photo', CmFileValidator::className(), 'skipOnEmpty' => false],\r\n\t\t....\r\n\t];\r\n}\r\n```\r\nAttribute \"photo\" sets by own logic in behaviour and it should has correct value from DB.\r\nWith rules above after `$model->load()` attribute \"photo\" sets as null.\r\nIf I add \"!\" before attribute in rules - validator doesnt runs. \r\n\r\nI find only this way for unsafe attribute using with validator's running:\r\n```\r\npublic function scenarios()\r\n{\r\n\t$scenarios = parent::scenarios();\r\n\t$photoKey = array_search('photo', $scenarios['default']);\r\n\t$scenarios['default'][$photoKey] = '!photo';\r\n\treturn $scenarios;\r\n}\r\n```\r\n\r\nIs this the only solution?"}}