convert some React fields to ES6

- renamed empty label to placeholder
This commit is contained in:
Jonathan Labreuille
2016-05-19 15:19:31 +02:00
parent 6074aa927b
commit 4c265d1339
4 changed files with 93 additions and 104 deletions

View File

@@ -1,40 +1,35 @@
define([
'react'
],
function(
React
) {
const FormFieldText = React.createClass({
render: function() {
let value = this.props.item[this.props.field.name];
if(value === undefined) {
value = this.props.field.defaultValue || '';
}
import React from 'react'
return (
<input
type="text"
disabled={
(this.props.field['disabled'] !== undefined)
? this.props.field.disabled(this.props.item)
: false
}
className={ (this.props.field.size) ? '' : 'regular-text' }
size={
(this.props.field.size !== 'auto' && this.props.field.size > 0)
? this.props.field.size
: false
}
name={ this.props.field.name }
id={ 'field_'+this.props.field.name }
value={ value }
placeholder={ this.props.field.placeholder }
onChange={ this.props.onValueChange }
{...this.props.field.validation}
/>
);
const FormFieldText = React.createClass({
render() {
let value = this.props.item[this.props.field.name];
if (value === undefined) {
value = this.props.field.defaultValue || '';
}
});
return FormFieldText;
return (
<input
type="text"
disabled={
(this.props.field['disabled'] !== undefined)
? this.props.field.disabled(this.props.item)
: false
}
className={ (this.props.field.size) ? '' : 'regular-text' }
size={
(this.props.field.size !== 'auto' && this.props.field.size > 0)
? this.props.field.size
: false
}
name={ this.props.field.name }
id={ 'field_'+this.props.field.name }
value={ value }
placeholder={ this.props.field.placeholder }
onChange={ this.props.onValueChange }
{...this.props.field.validation}
/>
);
}
});
module.exports = FormFieldText;