ES6 assets/js/src/form/fields/checkbox.jsx

This commit is contained in:
Amine Ben hammou
2018-04-18 11:58:54 +02:00
parent 6892dbea91
commit 5ac75591a9

View File

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