{"action":"created","issue":{"url":"https://api.github.com/repos/bem/bem-components/issues/1262","labels_url":"https://api.github.com/repos/bem/bem-components/issues/1262/labels{/name}","comments_url":"https://api.github.com/repos/bem/bem-components/issues/1262/comments","events_url":"https://api.github.com/repos/bem/bem-components/issues/1262/events","html_url":"https://github.com/bem/bem-components/issues/1262","id":54710084,"number":1262,"title":"checkbox: Send off to server","user":{"login":"tadatuta","id":475746,"avatar_url":"https://avatars.githubusercontent.com/u/475746?v=3","gravatar_id":"","url":"https://api.github.com/users/tadatuta","html_url":"https://github.com/tadatuta","followers_url":"https://api.github.com/users/tadatuta/followers","following_url":"https://api.github.com/users/tadatuta/following{/other_user}","gists_url":"https://api.github.com/users/tadatuta/gists{/gist_id}","starred_url":"https://api.github.com/users/tadatuta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tadatuta/subscriptions","organizations_url":"https://api.github.com/users/tadatuta/orgs","repos_url":"https://api.github.com/users/tadatuta/repos","events_url":"https://api.github.com/users/tadatuta/events{/privacy}","received_events_url":"https://api.github.com/users/tadatuta/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bem/bem-components/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-01-18T21:04:31Z","updated_at":"2015-01-19T07:47:34Z","closed_at":null,"body":"I propose to improve native `checkbox` behaviour and always send values to a server even if a checkbox is off (maybe as a separate modifier).\r\n\r\nCan be implemented with the help of hidden input like this:\r\n```js\r\nblock('checkbox').content()(function() {\r\n    var isChecked = this.mods.checked;\r\n\r\n    return [\r\n        {\r\n            elem: 'hidden',\r\n            tag: 'input',\r\n            attrs: {\r\n                type: 'hidden',\r\n                name: this.ctx.name,\r\n                disabled: isChecked ? 'disabled' : undefined,\r\n                value: isChecked ? '' : 'off'\r\n            }\r\n        },\r\n        applyNext()\r\n    ];\r\n});\r\n```\r\n\r\nand\r\n```js\r\nmodules.define('checkbox', function(provide, Checkbox) {\r\n    provide(Checkbox.decl({\r\n        _onChange: function() {\r\n            this.__base.apply(this, arguments);\r\n\r\n            this.elem('hidden').prop(this.elem('control').prop('checked') ?\r\n                { disabled: 'disabled' } : { value: 'off', disabled: false });\r\n        }\r\n    }));\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/bem/bem-components/issues/comments/70456360","html_url":"https://github.com/bem/bem-components/issues/1262#issuecomment-70456360","issue_url":"https://api.github.com/repos/bem/bem-components/issues/1262","id":70456360,"user":{"login":"tadatuta","id":475746,"avatar_url":"https://avatars.githubusercontent.com/u/475746?v=3","gravatar_id":"","url":"https://api.github.com/users/tadatuta","html_url":"https://github.com/tadatuta","followers_url":"https://api.github.com/users/tadatuta/followers","following_url":"https://api.github.com/users/tadatuta/following{/other_user}","gists_url":"https://api.github.com/users/tadatuta/gists{/gist_id}","starred_url":"https://api.github.com/users/tadatuta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tadatuta/subscriptions","organizations_url":"https://api.github.com/users/tadatuta/orgs","repos_url":"https://api.github.com/users/tadatuta/repos","events_url":"https://api.github.com/users/tadatuta/events{/privacy}","received_events_url":"https://api.github.com/users/tadatuta/received_events","type":"User","site_admin":false},"created_at":"2015-01-19T07:47:34Z","updated_at":"2015-01-19T07:47:34Z","body":"@dfilatov when you submit a form with switched off checkbox there's no way on schemaless backend to understand if you want to leave it's value unchanged or want to remove it as nothing is sent at all. also you can't differentiate unknown state from intentionally switched off."}}