@@ -13,16 +13,11 @@ import ReactSelect from "../../components/ReactSelect";
13
13
import DateInput from "../../components/DateInput" ;
14
14
import "./styles.module.scss" ;
15
15
16
- const updateInput = ( field , input ) => {
17
- field . input = input ;
18
- }
19
-
20
16
const FormField = ( { field, isGroupField } ) => {
21
17
return (
22
18
< Field name = { field . name } >
23
19
{ ( { input, meta } ) => (
24
20
< div styleName = { isGroupField ? "field-group-field" : "" } >
25
- { updateInput ( field , input ) }
26
21
{ ! field . readonly && (
27
22
< label
28
23
styleName = {
@@ -40,7 +35,7 @@ const FormField = ({ field, isGroupField }) => {
40
35
placeholder = { field . placeholder }
41
36
value = { input . value ?? "" }
42
37
type = "text"
43
- className = { meta . error && meta . touched ? "error" : "" }
38
+ className = { meta . error && ( meta . touched || field . showError ) ? "error" : "" }
44
39
readonly = { field . readonly }
45
40
onChange = { input . onChange }
46
41
onBlur = { input . onBlur }
@@ -56,7 +51,7 @@ const FormField = ({ field, isGroupField }) => {
56
51
onChange = { input . onChange }
57
52
onBlur = { input . onBlur }
58
53
onFocus = { input . onFocus }
59
- className = { meta . error && meta . touched ? "error" : "" }
54
+ className = { meta . error && ( meta . touched || field . showError ) ? "error" : "" }
60
55
/>
61
56
) }
62
57
{ field . type === FORM_FIELD_TYPE . TEXTAREA && (
@@ -66,7 +61,7 @@ const FormField = ({ field, isGroupField }) => {
66
61
onChange = { input . onChange }
67
62
onBlur = { input . onBlur }
68
63
onFocus = { input . onFocus }
69
- className = { meta . error && meta . touched ? "error" : "" }
64
+ className = { meta . error && ( meta . touched || field . showError ) ? "error" : "" }
70
65
/>
71
66
) }
72
67
{ field . type === FORM_FIELD_TYPE . DATE && (
@@ -76,7 +71,7 @@ const FormField = ({ field, isGroupField }) => {
76
71
onChange = { input . onChange }
77
72
onBlur = { input . onBlur }
78
73
onFocus = { input . onFocus }
79
- className = { meta . error && meta . touched ? "error" : "" }
74
+ className = { meta . error && ( meta . touched || field . showError ) ? "error" : "" }
80
75
/>
81
76
) }
82
77
{ field . type === FORM_FIELD_TYPE . SELECT && (
@@ -89,7 +84,7 @@ const FormField = ({ field, isGroupField }) => {
89
84
onFocus = { input . onFocus }
90
85
/>
91
86
) }
92
- { ( field . isRequired || field . customValidator ) && meta . error && meta . touched && (
87
+ { ( field . isRequired || field . customValidator ) && meta . error && ( meta . touched || field . showError ) && (
93
88
< div styleName = "field-error" > { meta . error } </ div >
94
89
) }
95
90
</ div >
@@ -117,7 +112,7 @@ FormField.prototype = {
117
112
maxLength : PT . number ,
118
113
styleName : PT . string ,
119
114
readonly : PT . string ,
120
- input : PT . object
115
+ showError : PT . bool
121
116
} )
122
117
) . isRequired ,
123
118
isGroupField : PT . bool ,
0 commit comments