ES6 assets/js/src/form/fields/radio.jsx
This commit is contained in:
@@ -1,41 +1,36 @@
|
|||||||
define([
|
import React from 'react';
|
||||||
'react',
|
|
||||||
],
|
|
||||||
(
|
|
||||||
React
|
|
||||||
) => {
|
|
||||||
const FormFieldRadio = React.createClass({
|
|
||||||
render: function render() {
|
|
||||||
if (this.props.field.values === undefined) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const selectedValue = this.props.item[this.props.field.name];
|
const FormFieldRadio = React.createClass({
|
||||||
const options = Object.keys(this.props.field.values).map(
|
render: function render() {
|
||||||
(value, index) => (
|
if (this.props.field.values === undefined) {
|
||||||
<p key={`radio-${index}`}>
|
return false;
|
||||||
<label htmlFor={this.props.field.name}>
|
}
|
||||||
<input
|
|
||||||
type="radio"
|
|
||||||
checked={selectedValue === value}
|
|
||||||
value={value}
|
|
||||||
onChange={this.props.onValueChange}
|
|
||||||
name={this.props.field.name}
|
|
||||||
id={this.props.field.name}
|
|
||||||
/>
|
|
||||||
{ this.props.field.values[value] }
|
|
||||||
</label>
|
|
||||||
</p>
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
const selectedValue = this.props.item[this.props.field.name];
|
||||||
<div>
|
const options = Object.keys(this.props.field.values).map(
|
||||||
{ options }
|
value => (
|
||||||
</div>
|
<p key={`radio-${value}`}>
|
||||||
);
|
<label htmlFor={this.props.field.name}>
|
||||||
},
|
<input
|
||||||
});
|
type="radio"
|
||||||
|
checked={selectedValue === value}
|
||||||
|
value={value}
|
||||||
|
onChange={this.props.onValueChange}
|
||||||
|
name={this.props.field.name}
|
||||||
|
id={this.props.field.name}
|
||||||
|
/>
|
||||||
|
{ this.props.field.values[value] }
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
return FormFieldRadio;
|
return (
|
||||||
|
<div>
|
||||||
|
{ options }
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export default FormFieldRadio;
|
||||||
|
Reference in New Issue
Block a user