fixes errors and labels with field-types

This commit is contained in:
James
2018-12-07 12:36:53 -08:00
parent dd8456767a
commit 07c8bacb2c
2 changed files with 7 additions and 7 deletions

View File

@@ -3,9 +3,7 @@ import { fieldType } from 'payload/components';
import './index.scss';
const errors = {
text: 'Please fill in the field'
};
const error = 'Please fill in the textarea';
const validate = value => value.length > 0;
@@ -27,4 +25,4 @@ const Textarea = props => {
);
}
export default fieldType(Textarea, 'textarea', validate, errors);
export default fieldType(Textarea, 'textarea', validate, error);

View File

@@ -61,8 +61,8 @@ const fieldType = (PassedComponent, slug, validate, errors) => {
<PassedComponent {...this.props}
className={className}
value={value}
Label={<Label {...this.props} />}
Error={<Error showError={showError} />}
label={<Label {...this.props} />}
error={<Error showError={showError} type={this.props.type} />}
onChange={e => {
this.sendField(e.target.value);
this.props.onChange && this.props.onChange(e);
@@ -90,7 +90,9 @@ const fieldType = (PassedComponent, slug, validate, errors) => {
if (props.showError) {
return (
<Tooltip className="error-message">
{errors[this.props.type]}
{props.type && errors[props.type]}
{!props.type && errors}
</Tooltip>
)
}