diff --git a/assets/js/src/form/fields/checkbox.jsx b/assets/js/src/form/fields/checkbox.jsx index 3da0378233..10d6fad58c 100644 --- a/assets/js/src/form/fields/checkbox.jsx +++ b/assets/js/src/form/fields/checkbox.jsx @@ -6,7 +6,7 @@ function( ) { const FormFieldCheckbox = React.createClass({ onValueChange: function(e) { - e.target.value = this.refs.checkbox.checked ? '1' : ''; + e.target.value = this.refs.checkbox.checked ? '1' : '0'; return this.props.onValueChange(e); }, render: function() { @@ -14,7 +14,9 @@ function( return false; } - const isChecked = !!(this.props.item[this.props.field.name]); + // isChecked will be true only if the value is "1" + // it will be false in case value is "0" or empty + const isChecked = !!(~~(this.props.item[this.props.field.name])); const options = Object.keys(this.props.field.values).map( (value, index) => { return ( diff --git a/lib/Form/Block/Checkbox.php b/lib/Form/Block/Checkbox.php index cb8ac2f028..37c77bff64 100644 --- a/lib/Form/Block/Checkbox.php +++ b/lib/Form/Block/Checkbox.php @@ -22,7 +22,7 @@ class Checkbox extends Base { foreach($options as $option) { $html .= '