1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

Property component now propagate its name to its input child

This commit is contained in:
vrde 2015-10-14 15:30:10 +02:00
parent 7af4e0912e
commit 01cea9ad3d
2 changed files with 10 additions and 4 deletions

View File

@ -17,11 +17,13 @@ let InputCheckbox = React.createClass({
// //
// Since this component even has checkbox in its name, it felt wrong to expose defaultValue // Since this component even has checkbox in its name, it felt wrong to expose defaultValue
// as the default-setting prop to other developers, which is why we choose defaultChecked. // as the default-setting prop to other developers, which is why we choose defaultChecked.
defaultValue: React.PropTypes.string,
defaultChecked: React.PropTypes.bool, defaultChecked: React.PropTypes.bool,
children: React.PropTypes.oneOfType([ children: React.PropTypes.oneOfType([
React.PropTypes.arrayOf(React.PropTypes.element), React.PropTypes.arrayOf(React.PropTypes.element),
React.PropTypes.element React.PropTypes.element
]), ]),
name: React.PropTypes.string,
// provided by Property // provided by Property
disabled: React.PropTypes.bool, disabled: React.PropTypes.bool,
@ -102,8 +104,10 @@ let InputCheckbox = React.createClass({
return ( return (
<span <span
style={this.props.style} style={this.props.style}
onClick={this.onChange}> onClick={this.onChange}
name={this.props.name}>
<input <input
name={this.props.name}
type="checkbox" type="checkbox"
ref="checkbox" ref="checkbox"
onChange={this.onChange} onChange={this.onChange}
@ -119,4 +123,4 @@ let InputCheckbox = React.createClass({
} }
}); });
export default InputCheckbox; export default InputCheckbox;

View File

@ -31,6 +31,7 @@ let Property = React.createClass({
footer: React.PropTypes.element, footer: React.PropTypes.element,
handleChange: React.PropTypes.func, handleChange: React.PropTypes.func,
ignoreFocus: React.PropTypes.bool, ignoreFocus: React.PropTypes.bool,
name: React.PropTypes.string.isRequired,
className: React.PropTypes.string, className: React.PropTypes.string,
onClick: React.PropTypes.func, onClick: React.PropTypes.func,
@ -210,7 +211,8 @@ let Property = React.createClass({
onFocus: this.handleFocus, onFocus: this.handleFocus,
onBlur: this.handleBlur, onBlur: this.handleBlur,
disabled: !this.props.editable, disabled: !this.props.editable,
ref: 'input' ref: 'input',
name: this.props.name
}); });
}); });
}, },
@ -260,4 +262,4 @@ let Property = React.createClass({
} }
}); });
export default Property; export default Property;