I've got a templated TextAreaField that uses FormControl
from react-bootstrap
to give it the nice bootstrap look and feel.
I'm wanting to be able to use internationalised messages via react-intl
. It works for all the components outside the FormControl
, but not in the props. When I try and pass a FormattedMessage
to the placeholder
it just displays [object Object]
Any ideas?
TextAreaField.js
import React, {PropTypes} from 'react';
import Help from './Help';
import {FormGroup, ControlLabel, FormControl } from 'react-bootstrap';
const TextAreaField = ({ input, label, tooltip, rows, meta }) => {
const { touched, warning, error} = meta;
let currentState = null;
if (touched) currentState = (error ? "error" : warning ? "warning" : null);
return (
<FormGroup controlId={input.name} validationState={currentState}>
{tooltip && <Help input={input.name} text={tooltip}/>}
<FormControl
componentClass="textarea"
style={{height: rows * 2 + "em"}}
placeholder={label}
{...input}
/>
{currentState && <ControlLabel className={currentState}>{error || warning}</ControlLabel>}
</FormGroup>
);
};
TextAreaField.propTypes = {
input: PropTypes.object.isRequired,
label: PropTypes.object.isRequired,
tooltip: PropTypes.object,
meta: PropTypes.object,
rows: PropTypes.number,
};
TextAreaField.defaultProps = {
rows: 3
};
export default TextAreaField;
The redux-form that uses the TextAreaField
<Field name="text" label={<FormattedMessage id="Order.Text" />} validate={required}
warn={bigJob} component={TextAreaField} rows={5}/>