UNPKG

reactui

Version:

A components library for ReactJS. This is part of the Gearz project

35 lines (31 loc) 1.19 kB
define(["exports"], function (exports) { "use strict"; var React = require("react"); var gearzMixin = require("../../gearz.mixin"); var FormGroup = React.createClass({ displayName: "FormGroup", mixins: [gearzMixin], propTypes: { // The display name displayName: React.PropTypes.string.isRequired, // The child (single one) that represents the inner-control to be rendered inside the FormGroup children: React.PropTypes.element.isRequired }, render: function render() { var displayName = this.get("displayName"); var childId = this.props.children.props.id; var childInvalid = this.props.children.props.invalid; return React.createElement( "div", { className: childInvalid ? "form-group has-error" : "form-group" }, React.createElement( "label", { htmlFor: childId, className: "control-label" }, displayName ), this.props.children ); } }); module.exports = FormGroup; });