{"action":"closed","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/7308","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/7308/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/7308/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/7308/events","html_url":"https://github.com/yiisoft/yii2/issues/7308","id":57786710,"number":7308,"title":"File upload behaves strange when updating a record","user":{"login":"iamwebdesigner","id":8792609,"avatar_url":"https://avatars.githubusercontent.com/u/8792609?v=3","gravatar_id":"","url":"https://api.github.com/users/iamwebdesigner","html_url":"https://github.com/iamwebdesigner","followers_url":"https://api.github.com/users/iamwebdesigner/followers","following_url":"https://api.github.com/users/iamwebdesigner/following{/other_user}","gists_url":"https://api.github.com/users/iamwebdesigner/gists{/gist_id}","starred_url":"https://api.github.com/users/iamwebdesigner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iamwebdesigner/subscriptions","organizations_url":"https://api.github.com/users/iamwebdesigner/orgs","repos_url":"https://api.github.com/users/iamwebdesigner/repos","events_url":"https://api.github.com/users/iamwebdesigner/events{/privacy}","received_events_url":"https://api.github.com/users/iamwebdesigner/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yiisoft/yii2/labels/status:to%20be%20verified","name":"status:to be verified","color":"fbca04"}],"state":"closed","locked":false,"assignee":{"login":"samdark","id":47294,"avatar_url":"https://avatars.githubusercontent.com/u/47294?v=3","gravatar_id":"","url":"https://api.github.com/users/samdark","html_url":"https://github.com/samdark","followers_url":"https://api.github.com/users/samdark/followers","following_url":"https://api.github.com/users/samdark/following{/other_user}","gists_url":"https://api.github.com/users/samdark/gists{/gist_id}","starred_url":"https://api.github.com/users/samdark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samdark/subscriptions","organizations_url":"https://api.github.com/users/samdark/orgs","repos_url":"https://api.github.com/users/samdark/repos","events_url":"https://api.github.com/users/samdark/events{/privacy}","received_events_url":"https://api.github.com/users/samdark/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2015-02-16T10:21:07Z","updated_at":"2015-02-17T09:36:07Z","closed_at":"2015-02-17T09:36:07Z","body":"I am using file upload input with model and when I try to update a record without uploading a file, values respective to file inputs in the record are lost. I managed to solve this problem, after I made a little change in framework code.  \r\nFile: framework/helpers/BaseHtml.php  \r\nChanged (in line 1212):  \r\n**from:**  \r\n```\r\n    public static function activeFileInput($model, $attribute, $options = [])\r\n    {\r\n        // add a hidden field so that if a model only has a file field, we can\r\n        // still use isset($_POST[$modelClass]) to detect if the input is submitted\r\n        return static::activeHiddenInput($model, $attribute, ['id' => null, 'value' => ''])\r\n            . static::activeInput('file', $model, $attribute, $options);\r\n    }\r\n```\r\n**to:**\r\n```\r\n    public static function activeFileInput($model, $attribute, $options = [])\r\n    {\r\n        // add a hidden field so that if a model only has a file field, we can\r\n        // still use isset($_POST[$modelClass]) to detect if the input is submitted\r\n        $options['value'] = '';\r\n        return static::activeHiddenInput($model, $attribute, ['id' => null])\r\n            . static::activeInput('file', $model, $attribute, $options);\r\n    }\r\n```\r\nI guess, if there is another solution without changing a framework source, it is necessary to include it in the documentation."}}