Skip to content

Commit

Permalink
conditional styling
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenGrider committed Apr 20, 2017
1 parent 0bf04da commit 1e2b20c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions blog/src/components/posts_new.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ import { Field, reduxForm } from 'redux-form';

class PostsNew extends Component {
renderField(field) {
const { meta: { touched, error } } = field;
const className = `form-group ${touched && error ? 'has-danger' : ''}`;

return (
<div className="form-group">
<div className={className}>
<label>{field.label}</label>
<input
className="form-control"
type="text"
{...field.input}
/>
{field.meta.touched ? field.meta.error : ''}
<div className="text-help">
{touched ? error : ''}
</div>
</div>
);
}
Expand Down

0 comments on commit 1e2b20c

Please sign in to comment.