ES6 assets/js/src/form/fields/checkbox.jsx
This commit is contained in:
@@ -1,10 +1,6 @@
|
|||||||
define([
|
import React from 'react';
|
||||||
'react',
|
|
||||||
],
|
const FormFieldCheckbox = React.createClass({
|
||||||
(
|
|
||||||
React
|
|
||||||
) => {
|
|
||||||
const FormFieldCheckbox = React.createClass({
|
|
||||||
onValueChange: function onValueChange(e) {
|
onValueChange: function onValueChange(e) {
|
||||||
e.target.value = this.checkbox.checked ? '1' : '0';
|
e.target.value = this.checkbox.checked ? '1' : '0';
|
||||||
return this.props.onValueChange(e);
|
return this.props.onValueChange(e);
|
||||||
@@ -18,8 +14,8 @@ define([
|
|||||||
// it will be false in case value is "0" or empty
|
// it will be false in case value is "0" or empty
|
||||||
const isChecked = !!(Number(this.props.item[this.props.field.name]));
|
const isChecked = !!(Number(this.props.item[this.props.field.name]));
|
||||||
const options = Object.keys(this.props.field.values).map(
|
const options = Object.keys(this.props.field.values).map(
|
||||||
(value, index) => (
|
value => (
|
||||||
<p key={`checkbox-${index}`}>
|
<p key={`checkbox-${value}`}>
|
||||||
<label htmlFor={this.props.field.name}>
|
<label htmlFor={this.props.field.name}>
|
||||||
<input
|
<input
|
||||||
ref={(c) => { this.checkbox = c; }}
|
ref={(c) => { this.checkbox = c; }}
|
||||||
@@ -42,7 +38,6 @@ define([
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
|
||||||
|
|
||||||
return FormFieldCheckbox;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export default FormFieldCheckbox;
|
||||||
|
Reference in New Issue
Block a user