Note the use of the important props value, onChange and label which are
provided by the form builder. Other props such as help are passed through from
the <Field /> proxy components used above.
Overriding the default field component
// as long as a component takes a `value` prop (and ideally a `label` prop)// and an `onChange` callback prop, it can be used as a react-form-for fieldvar Input = require('react-bootstrap/Input')var {Form, Fields, Field} = require('react-form-for')var ExampleForm = React.createClass({ handleChange: function(updatedValue) { this.setState({value: updatedValue}) }, // the checkbox Field gets an Input component with different layout classes getCheckboxComponent: function() { return ( <Input type="checkbox" wrapperClassName="col-xs-offset-2 col-xs-10"/> ) }, render: function() { var formOpts = { onChange: this.handleChange, fieldComponent: ( <Input labelClassName="col-xs-2" wrapperClassName="col-xs-10" /> ) } // all of these fields will be rendered as a react-bootstrap/Input <Form for={this.state.value} {...formOpts} className="form-horizontal"> <Field for="name" /> <Field for="active" component={this.getCheckboxComponent()} /> <Fields for="financial_stuff" <Field for="account_balance" addonBefore="$" /> </Fields> </Form> ) }})
Warning
:warning: This module is pretty new and might have some bugs, please file an issue
if you encounter any problems.