File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,12 @@ function FormFields(props: FormFieldsProps): JSX.Element {
86
86
return (
87
87
< FormGroup key = { key } className = 'embedded' >
88
88
{ type === 'hidden' ? null : (
89
- < ControlLabel htmlFor = { key } > { label } </ ControlLabel >
89
+ < ControlLabel htmlFor = { key } >
90
+ { label }
91
+ { required . includes ( name ) && (
92
+ < span className = 'required-star' > *</ span >
93
+ ) }
94
+ </ ControlLabel >
90
95
) }
91
96
< FormControl
92
97
componentClass = { type === 'textarea' ? type : 'input' }
Original file line number Diff line number Diff line change
1
+ import { FORM_ERROR } from 'final-form' ;
1
2
import React , { FormEvent } from 'react' ;
2
3
import { Form } from 'react-final-form' ;
3
4
@@ -45,6 +46,17 @@ function DynamicForm({
45
46
onSubmit = { ( values : URLValues , ...args : unknown [ ] ) => {
46
47
submit ( formatUrlValues ( values , options ) , ...args ) ;
47
48
} }
49
+ validate = { ( values : URLValues ) => {
50
+ const hasMissingRequiredFields = options . required ?. some (
51
+ ( field : string ) => ! values [ field ]
52
+ ) ;
53
+
54
+ return hasMissingRequiredFields
55
+ ? {
56
+ [ FORM_ERROR ] : hasMissingRequiredFields
57
+ }
58
+ : undefined ;
59
+ } }
48
60
>
49
61
{ ( { handleSubmit, pristine, error } ) => (
50
62
< form
Original file line number Diff line number Diff line change @@ -500,6 +500,10 @@ fieldset[disabled] .btn-primary.focus {
500
500
strong {
501
501
color : var (--secondary-color );
502
502
}
503
+ .required-star {
504
+ color : red;
505
+ margin-left : 3px ;
506
+ }
503
507
504
508
.form-group .embedded {
505
509
border : 1px solid var (--tc-black-40 );
You can’t perform that action at this time.
0 commit comments